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

Thats nice. Thanks. Where did you find it.
I think it is from somewhere in standard library.