pep 336: Make None Callable
__peter__ at web.de
Thu Nov 4 11:01:24 CET 2004
The Eternal Squire wrote:
> None should be a callable object that when called with any
> arguments has no side effect and returns None.
Why would you stop there?
>>> class BusyNone(object):
... def __call__(self, *args, **kw):
... return BusyNone
... __getattr__ = __getitem__ = __add__ = __call__
... def __str__(self):
... return "BusyNone"
... __repr__ = __str__
>>> BusyNone = BusyNone()
>>> BusyNone("a", 1)
>>> BusyNone + 42
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: len() of unsized object
Still room for improvement, but you should get the idea...
More information about the Python-list