[Python-3000] PEP 30xx: Access to Module/Class/Function CurrentlyBeing Defined (this)
Nicko van Someren
nicko at nicko.org
Sat Apr 28 18:14:41 CEST 2007
On 23 Apr 2007, at 05:17, Terry Reedy wrote:
> "Jim Jewett" <jimjjewett at gmail.com> wrote in
> news:fb6fbf560704222005le4798a4j5daa5e71e644f069 at mail.gmail.com...
> | Functions (including methods) often want access to themselves,
> | usually for a private storage location.
> Or for true recursion. At present, a function has to 'hope' that its
> definition name is not rebound.
Indeed. It's much clearing than having to write:
Y = lambda f: partial(f,f)
fac = Y(lambda f, n: n*f(f,n-1) if n>0 else 1)
Seriously though, while I have to confess never, ever having found
rebinding of function names a limiting factor in writing recursive
code I'm still in favour of the proposal. Personally I think
function-local storage is a more likely use.
More information about the Python-3000