Self function
MRAB
google at mrabarnett.plus.com
Tue May 5 18:33:34 EDT 2009
Steve Howell wrote:
> On May 4, 11:08 pm, Steven D'Aprano
> <ste... at REMOVE.THIS.cybersource.com.au> wrote:
>> I propose a small piece of sugar. When a function is entered, Python
>> creates an ordinary local name in the function's local namespace, and
>> binds the function itself to that name. Two possibilities for the name
>> are `this` or `__this__`, analogous to `self` in methods and `__name__`
>> in modules.
>>
>> If there is any support for this, I propose to send the following (long)
>> post to python-ideas. Feedback, corrections and suggestions welcome.
>>
>
> I totally support this proposal. I've definitely wasted time in the
> past trying to invent my own workarounds for the use cases you
> describe.
>
> Obviously, there will be some bikeshed debates on __this__ vs.
> __name__ vs. __func__, etc. I don't have an opinion there, just want
> *something* handy for introspection, DRYness, etc.
>
> A more interesting question is whether __this__ would just always be
> there (that's my vote), or if you should have to apply a special
> decorator to get it (which I oppose, but I can see some merits).
>
I'd say that __this__ is a little unclear, so I'd choose __func__.
More information about the Python-list
mailing list