[Tutor] tokenize row numbering
Chris Smith
smichr at bigfoot.com
Tue May 3 16:21:06 CEST 2005
> From: Andrei <project5 at redrival dot net
>
>> ###
>> # line 1 according to tokenize tuple
>> # line 2
>> a=b #line 3
>> ###
>>
>> Does anyone have an idea of *why* the rows/physical lines of code
>> beginning their count at 1 instead of 0? In order to process the code
>> I
>
> The snippet above shows that numbering begins at 0, with the fourth
> line having
> number 3. So either I misunderstand the question, or the snippet is
> confusing.
>
Sorry, don't count the ### which are snippet delimiters. Here's
another example I ran before sending this: for the single line program,
print "hello, world"
This is what comes back from the tokenizer:
NAME 'print' (1, 0) (1, 5)
STRING '"hello, world"' (1, 6) (1, 20)
ENDMARKER '' (2, 0) (2, 0)
It shows that 'print' starts at position 1,0 whereas if I were to
number the rows like I numbered the columns, it would be at position
0,0.
I was just wondering if someone knew a good reason for this, otherwise
I would submit it as a feature change at source forge. But I'm not sure
how long this behavior has been around and if people actually use this
information. I did, but what I ended up doing was adding 1 to every
row position returned by the tokenizer.
/c
More information about the Tutor
mailing list