[Python-ideas] Ruby-style Blocks in Python Idea

Steven D'Aprano steve at pearwood.info
Wed Mar 11 23:41:03 CET 2009

On Thu, 12 Mar 2009 01:26:29 am Guido van Rossum wrote:
> You can assign new values to to f.__name__.

But it is only used in function repr, not tracebacks. From Python 2.6:

>>> f = lambda x: x+1  # __name__ is '<lambda>'
>>> f.__name__ = 'f'
>>> f
<function f at 0xb7f0d304>
>>> f(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <lambda>
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Steven D'Aprano

More information about the Python-ideas mailing list