Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54978
| From | Piet van Oostrum <piet@vanoostrum.org> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Weird bahaviour from shlex - line no |
| Date | 2013-09-28 16:59 -0400 |
| Message-ID | <m2eh887jch.fsf@cochabamba.vanoostrum.org> (permalink) |
| References | <CAEvez=x1ySjRtR_7asYtU3FoRsC8c1g0g_OZQ_NE-Ok443bFrg@mail.gmail.com> <l26ljd$mrd$1@ger.gmane.org> <mailman.412.1380379896.18130.python-list@python.org> |
Peter Otten <__peter__@web.de> 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 <piet@vanoostrum.org> WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4]
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Weird bahaviour from shlex - line no Peter Otten <__peter__@web.de> - 2013-09-28 16:52 +0200 Re: Weird bahaviour from shlex - line no Piet van Oostrum <piet@vanoostrum.org> - 2013-09-28 16:59 -0400
csiph-web