What's the value of "None" between 2.1.1 and 1.5.2

Neil Schemenauer nas at python.ca
Fri Nov 30 12:44:17 EST 2001


Steve Holden wrote:
> But for your existing simulation, where you seem to be using None to
> record "No Value" (?) you can get away with
> 
>     something = min([x for x in a if x])

Nope:

    >>> a = [0.0, 1.0, None]
    >>> min([x for x in a if x])
    1.0

You want:

    min([x for x in a if x is not None])

Cheers,

  Neil




More information about the Python-list mailing list