Y
Hacker News
new
|
ask
|
show
|
jobs
by
vasachi
1969 days ago
I believe the idiom to check, if a parameter wasn’t set is to use an object() instance as default value.
_notset = object() def foo(x=_notset): if x is _notset: print("foo was called as foo()")
1 comments
andi999
1968 days ago
Thats nice. Thanks. Where did you find it.
link
vasachi
1967 days ago
I think it is from somewhere in standard library.
link