[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Function attributes

Terry Reedy

2/12/2010 5:31:00 AM

On 2/11/2010 6:36 PM, Gabriel Genellina wrote:

> This is simple to implement, but requires changing the function
> definition. My goal was to keep the original code unchanged, that is,
> leave it as:
>
> def f(n):
> if n > 0: return n*f(n-1)
> elif n==0: return 1
>
> (like a normal, recursive function), and make the 'f' inside the function
> body "magically" refer to the function itself.

Someone did this several years ago with a bytecode hack. I believe it
was in the cookbook. It was rejected as part of standard CPython.