comparison with None

brzrkr0 at gmail.com brzrkr0 at gmail.com
Wed Apr 18 18:34:40 EDT 2007


On Apr 18, 3:19 pm, Steven Howe <howe.ste... at gmail.com> wrote:
> I've read and found that 'None' comparisons is not always a good idea.
> Better to:
> from types import NoneType
>
> x = None
> if type( x ) == NoneType:
>     # true
>     < code >
> else:
>     # false; do something else.
>     < more code >
>
> Steven Howe

Is that any better than this?

if x is None:
    # do something
else:
    # do something else




More information about the Python-list mailing list