On Tue, Mar 4, 2014 at 10:02 AM, Roy Smith <[email protected]> wrote:
> In article <[email protected]>,
> Ben Finney <[email protected]> wrote:
>
>> That's right. Python provides this singleton and then recommends you
>> compare with ‘is’, precisely to protect against pathological cases like
>> a “return True when compared for equality with None” data type.
>
> Going off on a tangent, I've often wished Python provided more kinds of
> None-ness. I'll often write:
>
> def f(arg=None):
> whatever
>
> where it would be nice to differentiate between "this was called with no
> arguments" and "this was called with an argument of None".
That's why you have your own sentinel.
_NONE_PASSED=object()
def f(arg=_NONE_PASSED):
if f is not _NONE_PASSED: pass
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list