checking if a list is empty

Ian hobson42 at gmail.com
Wed May 11 17:02:19 EDT 2011


On 11/05/2011 20:13, Hans Georg Schaathun wrote:
> On Wed, 11 May 2011 12:17:33 -0700, Ethan Furman
>    <ethan at stoneleaf.us>  wrote:
> :  'if li' *is* KISS.
>
> It /might/ be in some contexts, but a priori it is not, as it
> superimposes a truth value on a data type which is otherwise
> a pretty accurate model of real objects (outside python).
>
> One principle of object oriented programming is to bestow the
> objects with properties reflecting known properties from the
> domain being modelled.  Lists do not have truth values in the
> application domain, and therefore truth values in the
> implementation domain is complicated.
>
Exactly. Its just a convention.  If it exists, its true, if if doesn't 
its false.

In the "real world"  lists of zero items do not exist.
You don't go shopping with a shopping list of zero items.
You don't take a journey going nowhere.
You wouldn't have a party and invite nobody.
What kind of building is one with zero floors?
Would you have an Aircraft Carrier with no aircraft?

Oh Wait - the UK has one of those coming into service soon.

Regards

Ian








More information about the Python-list mailing list