pep 336: Make None Callable
Alex Martelli
aleaxit at yahoo.com
Thu Nov 4 15:41:38 EST 2004
Terry Hancock <hancock at anansispaceworks.com> wrote:
...
> I just noticed though, that:
>
> noop = lambda *a, **kw: None
>
> is illegal (apparently lambda doesn't support argument indirection (or
> whatever that "*" syntax is properly called)). Never tried it before.
??? it's quite OK:
kallisti:~/cb/cha/oop/cba alex$ python2.3
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> lambda *a, **k: None
<function <lambda> at 0x61430>
> Maybe there should be a noop built-in, though?
A Null object, whether built-in on in the stdlib, sounds better to me.
Calling is just one of N operations you may want to do on it, after all!
Indexing, slicing, and so forth -- why not cover those, too?
Alex
More information about the Python-list
mailing list