Isn't None supposed to be false?

Anthony J Wilkinson anthony at dstc.edu.au
Tue May 2 23:42:25 EDT 2000


Yes - and it is - you just have the 'false' & 'true' strings in the wrong
place.

On Tue, 2 May 2000, Albert Wagner wrote:

> >>> x = None
> >>> if x:   
> ...     print 'false'
This is the true branch (when you print 'false').

> ... else:
> ...     print 'true'
This is the false branch (when you print 'true').

> ...
> true

The following example has the same problem.

> >>> if x == None:
> ...     print 'false'
> ... else:
> ...     print 'true'
> ...
> false                     

You would be better off printing 'spam' & 'foo' (or 'a' & 'b', etc) i.e.
completely arbitrary things that don't confuse the issue. Then afterwards look
at which branch executes and whether it was the right one or not.

Cheers,
Anthony
_____________________________________________________________________
Anthony J Wilkinson                               anthony at dstc.edu.au
Software Engineer                                http://www.fnorb.com
DSTC Pty Ltd                                     Ph:  +61 7 3365 4310





More information about the Python-list mailing list