Algorithm help per favore

David Eppstein eppstein at ics.uci.edu
Wed Jun 18 22:54:14 CEST 2003


On 6/18/03 3:45 PM -0500 Skip Montanaro <skip at pobox.com> wrote:
>     David> It's tempting to use "not L[0]" instead (since what I want is
> an     David> object that's not equal to L[0]) but that fails when L is
> empty.
>
> How about "not L[0:1]"?  Since L is a sequence (right?), "not L[0:1]" will
> be True if L is empty and False otherwise.

That fails to produce an object that is guaranteed to be unequal to L[0] 
when L is nonempty.
-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science






More information about the Python-list mailing list