John Posner a écrit :
On 2/10/2010 9:36 AM, Steven D'Aprano wrote:
On Wed, 10 Feb 2010 05:59:41 -0800, Muhammad Alkarouri wrote:
(snip)
def f(*args):
f.args = args
print args
(snip)
I completely agree with you. It is a wart that functions are only able to
refer to themselves by name, because if the name changes, things break.
Consider:
old_f = f # save the old version of the function
def f(x):
return old_f(x+1) # make a new function and call it f
This won't work correctly, because old_f still tries to refer to itself
under the name "f", and things break very quickly.
They didn't break immediately for me -- what am I missing?:
The fact that in the OP's snippet, code inside f's body refers to f by
its name.
--
http://mail.python.org/mailman/listinfo/python-list