checking if a list is empty

Ethan Furman ethan at stoneleaf.us
Sun May 8 00:57:13 EDT 2011


harrismh777 wrote:
> Steven D'Aprano wrote:
 >>>  attribution lost wrote:
>>> >  and implies in any case that li does not exist
>> It does nothing of the sort. If li doesn't exist, you get a NameError.
> 
>      That was the point.   'not' implies something that is not logical; 
> which is irony extreme since 'not' is typically considered a logical 
> operator.   What does it mean to say  not <list name>?  Well, apparently 
> it means the list is 'empty'... but why should it mean that? Why not 
> have it mean the list has been reversed in place?  Why not have it mean 
> that the list isn't homogeneous?  Why not have it mean that its not 
> mutable?  I could think of more... Why should 'not' mean 'empty'?

Because this is Python, and in Python that's what it means.

> 
>>> >  or worse is some kind of boolean.
>> Only if you're still thinking in some language that isn't Python.
> 
>    Which most of us are... hate to remind you...   Python is the new kid 
> on the block, and most of us are coming at this from multiple filters in 
> comp sci experience.  Its just the truth.

And your point would be?

If you're going to use a language, and use it well, you have to learn 
how that language works.

~Ethan~



More information about the Python-list mailing list