Peter Otten <[email protected]> writes: > Dave Angel wrote: > >> On 28/9/2013 02:26, Daniel Stojanov wrote: >> >>> 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. [...] > The explanation seems obvious: a word may be continued by the next character > if that is in wordchars, so the parser has to look at that character. If it > happens to be '\n' the lineno is immediately incremented. Non-wordchars are > returned as single characters, so there is no need to peek ahead and the > lineno is not altered. > > In short: this looks like an implementation accident.
I think shlex should be changed to give the line number of the start of the token in self.lineno. It isn't hard. -- Piet van Oostrum <[email protected]> WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
