Best way to check that you are at the beginning (the end) of an iterable?
Laurent
laurent.payot at gmail.com
Wed Sep 7 19:22:36 EDT 2011
I totally understand the performance issue that an hypothetical "istail" would bring, even if I think it would just be the programmer's responsibility not to use it when it's not certain that an end can be detected.
But I don't see why *adding* something like "ishead" would be so bad (at worse by using a boolean somewhere as you mentioned).
Anyway I was just asking if there is something better than enumerate. So the answer is no? The fact that I have to create a tuple with an incrementing integer for something as simple as checking that I'm at the head just sounds awfully unpythonic to me.
More information about the Python-list
mailing list