Comparison problem
Tim Henderson
tim.tadh at gmail.com
Mon Nov 28 00:19:53 EST 2005
peter
would not the more correct way to do this be short circuit
evaluation. somthing along lines of
if (len(item) > 0) and (item[0] == '-'): pass
seems to be the more correct approach. rather than relying on slicing
to return an empty string. For instance suppose you wanted to test to
see if than spot contained an empty string. If you used the slice
meathod you would be in a pickle. However in this particular case it
seems to be clear that the use of .startswith() is the single best
approach.
More information about the Python-list
mailing list