Something and nothing (Re: PEP 285: Adding a bool type)

Pearu Peterson pearu at cens.ioc.ee
Tue Apr 2 15:55:46 EST 2002


On 2 Apr 2002, Chris Barker wrote:

> WOW! fabulous post, Laura.

I agree.

> Laura Creighton wrote:
> 
> > Python does not distinguish between True and
> > False -- Python makes the distinction between something and nothing.
> 
> > So I out-and-out tell people this.  {} is a dictionary-shaped nothing.
> > [] is a list-shaped nothing. 0 is an integer-shaped nothing.
> > 0.0 is a float shaped nothing.
> 
> Thinking in terms of something vs. nothing is an excellent way to
> explain how Python treats these things, but I still have a problem with
> it. Who is to say that an empty list is nothing? or 0 for that matter. 0

You seem missed essential words in the definitions. Laura defined that
an empty list is a "list-shaped nothing", not just a "nothing".
You can think of a None as a true "nothing". 

Note that one can add certain "nothing" to an object (with the same type
as this "nothing") with an effect that there is no effect. 

This holds for strings, lists, tuples, numbers, in some sense also for
dictionaries, and trivially for None: there is no object with the same
type as None (except None itself, addition of None to None is yet
unimplemented feature in Python;-) that would be subject to the addition
of nothing.

Pearu





More information about the Python-list mailing list