slicing question: rawdata[j:j+1] == 'xx' #will this ever be true ??
richard.hsu at gmail.com
richard.hsu at gmail.com
Wed Apr 5 23:53:48 EDT 2006
I am new to python language and most of my python programming has been
done with IronPython.
I was looking at the source of markupbase.py which is included with
Python 2.4 and came across the following line of code:-
if rawdata[j:j+1] == '--': #comment
i was confused because based on my understanding of the slicing syntax,
rawdata[j:j+1] will either yield a string with ONE character or an
empty string, therefore this boolean comparison will always be False
because we are checking if it will be equal to a string with 2
characters!
am I missing something here ?
thank you in advance for educating me.
More information about the Python-list
mailing list