Self function

Rhodri James rhodri at
Wed May 6 23:20:29 CEST 2009

On Wed, 06 May 2009 04:59:59 +0100, Gabriel Genellina  
<gagsl-py2 at> wrote:

> En Tue, 05 May 2009 22:35:08 -0300, Rhodri James  
> <rhodri at> escribió:
>> On Tue, 05 May 2009 21:43:16 +0100, <bearophileHUGS at> wrote:
>>> wolfram.hinde...:
>>>> It is easy to change all references of the function name, except for
>>>> those in the function body itself? That needs some explantation.
>>> I can answer this. If I have a recursive function, I may want to
>>> create a similar function, so I copy and paste it, to later modify the
>>> copied version. Then to change its name I usually don't use a search &
>>> rename of its name into its block of code because it's usually
>>> useless. In non-recursive functions the name of the function is stated
>>> only once, at the top.
>> I'm sorry, but while I'm mildly positive towards the proposal (and more
>> so towards Aaron's decorator), I don't buy this argument at all.  What
>> is broken about your editor's global search-and-replace function that
>> makes it "usually useless" for making these name changes?
> It happened to me sometimes. If a module defines some functions, and it  
> doesn't *use* them, why should I use a global search-and-replace to  
> rename something? Modifying the "def" line should be enough - unless the  
> function happens to be recursive.

So the answer to my question would be "nothing"?

> It's the DRY principle in action, the same argument as when decorators  
> where introduced: there should be no need to repeat the function name  
> again and again.

Unless of course you're using it again and again, which you are.

Rhodri James *-* Wildebeeste Herder to the Masses

More information about the Python-list mailing list