[Python-Dev] Re: PEP 336, "Make None Callable", by Andrew McClelland

"Martin v. Löwis" martin at v.loewis.de
Sun Nov 7 19:20:50 CET 2004


Carlos Ribeiro wrote:
> Just a question, and I sincerely hope it's not a dumb one. Python
> already have a noop statement ("pass"). Now, what is being requested
> is a standard noop callable. Does it make sense -- both in
> theorethical and practical terms -- to allow a statement such as
> "pass" to be used in both situations? In other words, does it make
> sense to have a "unification" of sorts?

No. Theoretically, the "pass" statement exists for purely syntactical
purposes: namely, to put a statement where a statement is required, but
no meaningful statement can be found. As a result, "pass" has no
run-time semantics: it is not the case that it is executed and does
nothing, instead, it is simply not executed. The proposed "function
with no effect" would be quite different: it would have a run-time
semantics, which would be to ignore all arguments, and return None.

Practically, it would be very confusing if the keyword "pass" suddenly
started to denote a function. Traditionally, keywords have never
denoted expressions. It might be that True, False, and None become
keywords some day, but these would *only* be use as expressions.
It is unpythonic to give an expression meaning to a statement (just
as assignment is not an expression, either).

The simplest solution to achieve the rationale of the PEP would be
to add a function operator.nop. Of course, writing

def nop(*args):pass

isn't that more difficult than writing

from operator import nop

Regards,
Martin




More information about the Python-Dev mailing list