Accessing func_name from inside a function

Ron Adam rrr at ronadam.com
Mon Mar 27 00:48:40 CEST 2006


Alex Martelli wrote:
> Ron Adam <rrr at ronadam.com> wrote:
> 
>> A "Current" key word would fix this.  Or possibly "This" which would be
>> short for "This object".
> 
> I think "This" would cause huge confusion, since in other popular
> language the keyword "this" means (a pointer/reference to) "the instance
> variable on which the method is being called" -- my use is instead for
> "the object of the immediate lexically enclosing scope" (a module,
> class, or function).  Implementation wouldn't be trivial in today's
> CPython, anyway: frames have no references at all to function objects
> (only to _code_ objects), and class objects don't even exist untill well
> after their top-level code has long finished running; to make Current
> possible, these subtle points of semantics would have to be changed in
> quite a revolutionary way, especially where classes are concerned.
> 
> 
> Alex

Yes, I figured it would not be an easy or simple addition.  An easier 
alternative might be to be able to limit specific name rebindings.  Then 
some names could be depended on to always point to a specific object. 
Something like that would need to be used sparingly I think.

Cheers,
    Ron



More information about the Python-list mailing list