Function attributes

MRAB python at mrabarnett.plus.com
Wed Feb 10 12:23:36 EST 2010


Stephen Hansen wrote:
> On Wed, Feb 10, 2010 at 6:36 AM, Steven D'Aprano 
> <steve at remove-this-cybersource.com.au 
> <mailto:steve at remove-this-cybersource.com.au>> wrote:
> 
>     On Wed, 10 Feb 2010 05:59:41 -0800, Muhammad Alkarouri wrote:
>      > What is the simplest way to access the attributes of a function from
>      > inside it, other than using its explicit name? In a function like f
> 
>     Not built-in.
> 
>      > I am guessing the next question will be: should I really care? It
>     just
>      > feels like there should be a way, but I am not able to verbalise
>     a valid
>      > one at the moment, sorry.
> 
>     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.
> 
> 
> I agree its slightly... in-elegant, or sub-optimal, but I'm not sure I 
> want to call it a *wart*. If one calls it a wart, there might be 
> inspiration to fix it.
> 
> And this sounds like a precursor to making "self" non-explicit, and I 
> *really* like my explicit self. :)
> 
> Then again, I have been slightly bruised by this sub-optimal situation 
> before.
> 
> I tried to do a function using a frame hack to get the information 
> easily, but failed. My long years of avoiding frame hacks like the 
> plague have left me deficient. :(
> 
Does this mean that Python needs, say, __function__ (and perhaps also
__module__)?



More information about the Python-list mailing list