blob: f5949af844449309a0fdd121124260094a532b2e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
Ever needed a global object that act as None but not quite? Like for example
keyword argument for function, where None make sense, so you need a default
value.
One solution is to create as singleton object:
mysingleton = object()
Though it becomes difficult to track the singleton across libraries, and teach
users where to import this from. It's also relatively annoying use this
singleton across library.
Introducing undefined:
>>> import undefined
>>> from undefined import Undefined
>>> undefined is Undefined
True
|