pep 336: Make None Callable

  • Thread starter The Eternal Squire
  • Start date
T

Terry Hancock

Terry Hancock said:
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.<function <lambda> at 0x61430>

Oh DUH! I actually typed:

noop = lambda *a, *kw: None

which *is* a syntax error of course. Sorry about that. That's
a relief.

Terry
 
G

Greg Ewing

Dave said:
I think Objective C does something similar--is this the case?

Yes, and I worry about the potential to for it to hide
bugs in that language, too. I think Python has it right,
here.
 
B

Benji York

Chris said:
Even when we type it: None. it's the only builtin that is
capitalized.
Hmm.
print '\n'.join([name for name in dir(__builtins__) if name[0].isupper()])
ArithmeticError
AssertionError
AttributeError
DeprecationWarning
EOFError
Ellipsis
EnvironmentError
Exception
False
FloatingPointError
FutureWarning
IOError
ImportError
IndentationError
IndexError
KeyError
KeyboardInterrupt
LookupError
MemoryError
NameError
None
NotImplemented
NotImplementedError
OSError
OverflowError
OverflowWarning
PendingDeprecationWarning
ReferenceError
RuntimeError
RuntimeWarning
StandardError
StopIteration
SyntaxError
SyntaxWarning
SystemError
SystemExit
TabError
True
TypeError
UnboundLocalError
UnicodeDecodeError
UnicodeEncodeError
UnicodeError
UnicodeTranslateError
UserWarning
ValueError
Warning
WindowsError
ZeroDivisionError
 
M

Mike Meyer

The Eternal Squire said:
It would be more sensible to promote the addition to builtins of a
predefined null function -- one somewhat equivalent to 0, [], and {}.

I'd like to see it standardized, and I'd like to see it intuitively
obvious. That's why None appears to me to be such an obvious
candidate.

How about nop?

The real problem with allowing None to act as a function is that it
turns exceptions into very obscure bugs. Actually, this argument
applies to allowing one to do anything with None.

So I'm against it, even in Python-3000.

<mike
 
C

Chris Cioffi

Ouch. Ok...

<lame face saving attempt>At least _most_ of those are classes as
opposed to primitives...</lame face saving attempt>

Chris


Chris said:
Even when we type it: None. it's the only builtin that is
capitalized.
Hmm.
print '\n'.join([name for name in dir(__builtins__) if name[0].isupper()])
ArithmeticError
AssertionError
AttributeError
DeprecationWarning
EOFError
Ellipsis
EnvironmentError
Exception
False
FloatingPointError
FutureWarning
IOError
ImportError
IndentationError
IndexError
KeyError
KeyboardInterrupt
LookupError
MemoryError
NameError
None
NotImplemented
NotImplementedError
OSError
OverflowError
OverflowWarning
PendingDeprecationWarning
ReferenceError
RuntimeError
RuntimeWarning
StandardError
StopIteration
SyntaxError
SyntaxWarning
SystemError
SystemExit
TabError
True
TypeError
UnboundLocalError
UnicodeDecodeError
UnicodeEncodeError
UnicodeError
UnicodeTranslateError
UserWarning
ValueError
Warning
WindowsError
ZeroDivisionError
 
B

Benji York

Chris said:
<lame face saving attempt>At least _most_ of those are classes as
opposed to primitives...</lame face saving attempt>

No face-saving needed. :) The most used ones are None, True, and False
which are indeed "primitives". I was just being a bit pedantic.
 
C

Chris Cioffi

It was actually very educational. I use many, well, several, of those
exceptions often and although I don't import them, it never occured to
me that they were builtins!

Chris
 
A

Anthony Baxter

I completely agree. As a note, I can remind a
PEP 312 -- Simple Implicit Lambda. So with implicit lambda this is just

:None

"Syntax should not look like grit on my monitor"
 
J

Jeremy Bowers

PEP: 336
Title: Make None Callable

Backwards compatibility? I don't see any addressing of this at all, even
to dismiss it. Making None callable can obscure errors in existing code.

Otherwise, I'm pretty neutral on the idea for the semi-mythical Python
3000.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top