Alf P. Steinbach wrote: > * Peter Otten: >> Alf P. Steinbach wrote: >>> * Peter Otten: >>>> unidiomatic None-checks >>> What's the idiomatic Python way for an optional thing? >> >> if some_value is None: ... > > Thanks! > > But why is this preferred?
I guess because `some_value == None` restricts your choices if you want to give some_value's usual class an __eq__ method. It's a pretty arcane point.. but perhaps not.. the object named "some_value" might belong to a class that expects its instances only to be compared with each other, for the sake of economy and clear code. Mel. -- http://mail.python.org/mailman/listinfo/python-list