D
Daniel Stojanov
Can somebody explain this. The line number reported by shlex depends
on the previous token. I want to be able to tell if I have just popped
the last token on a line.
import shlex
first = shlex.shlex("word1 word2\nword3")
print first.get_token()
print first.get_token()
print "line no", first.lineno, "\n"
second = shlex.shlex("word1 word2,\nword3")
print second.get_token()
print second.get_token()
print second.get_token()
print "line no", second.lineno, "\n"
OUTPUT:
word1
word2
line no 2
word1
word2
,
line no 1
on the previous token. I want to be able to tell if I have just popped
the last token on a line.
import shlex
first = shlex.shlex("word1 word2\nword3")
print first.get_token()
print first.get_token()
print "line no", first.lineno, "\n"
second = shlex.shlex("word1 word2,\nword3")
print second.get_token()
print second.get_token()
print second.get_token()
print "line no", second.lineno, "\n"
OUTPUT:
word1
word2
line no 2
word1
word2
,
line no 1