Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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()")


Thats nice. Thanks. Where did you find it.


I think it is from somewhere in standard library.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: