Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
vasachi
on Feb 5, 2021
|
parent
|
context
|
favorite
| on:
Python’s tug of war between beginner-friendly and ...
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()")
andi999
on Feb 5, 2021
[–]
Thats nice. Thanks. Where did you find it.
vasachi
on Feb 6, 2021
|
parent
[–]
I think it is from somewhere in standard library.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: