pep 336: Make None Callable

Terry Hancock hancock at
Thu Nov 4 06:12:50 CET 2004

On Wednesday 03 November 2004 10:23 pm, Terry Reedy wrote:
> "The Eternal Squire" <eternalsquire at> wrote in message 
> news:dv6dndASE7CxNBTcRVn-pw at
> > PEP: 336
> > Abstract
> >     None should be a callable object that when called with any
> >     arguments has no side effect and returns None.
> Please no.  The None object, by definition, is an object with no value, no 
> behavior (except compares), and no specific attributes (other than those 
> common to all descendents of object).  That one can currently compare None 
> to other objects can be considered a bug, and this might go away in the 
> future.

Maybe. But all this requires, really, is to make None fail silently when
called instead of raising an error as it does now.  That could be seen
as quite consistent with its null nature, IMHO.

> Anyone who wants a null function can write it in about 20 keypresses, and 
> include it in a utility module if one has one.

True, and I have done so. But that's "20 keypresses" repeated a lot. And
what's it called? "do_nothing()" (my usual name), "null_function()", 
"null()", "empty()", "NoneFunc()" etc?  Furthermore, it's much more obvious
to store "None" when you want nothing to happen.  I usually instead
provide code in the caller to check for a None (or generic "False")
state before calling, like so:

if func: func()

Is there a good use case where this rather concise idiom won't do?
> It would be more sensible to promote the addition to builtins of a 
> predefined null function -- one somewhat equivalent to 0, [], and {}.

Maybe, but I think it's worth asking -- what use is the traceback from
the None object when it is called?  Does it help in QA of code?  Is
there a common idiom that would be broken by a callable None?

Terry Hancock ( hancock at )
Anansi Spaceworks

More information about the Python-list mailing list