Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
0 points
vasachi
5y ago
0 comments
Save
Share
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()")
0 comments
2 comments · 1 top-level
top
newest
oldest
andi999
5y ago
· 1 in thread
Thats nice. Thanks. Where did you find it.
vasachi
OP
5y ago
I think it is from somewhere in standard library.
j
/
k
navigate · click thread line to collapse