Is it advisable to replace 'self' with '_' or 'I' or something

jerf at compy.attbi.com jerf at compy.attbi.com
Mon Jan 13 19:24:43 EST 2003


On Mon, 13 Jan 2003 10:52:24 -0500, Mel Wilson wrote:
>    As a tiny addition: I seem to find it more useful to
> rebind entire variables, so that I write
> 
>     t = self.tree
>     t.yadayada()
>     t.usw ()
> 
> rather than
> 
>     s = self
>     s.tree.yadayada()
>     s.tree.usw ()

This hews close to one of my pet peeves, which I see a *lot* of in Windows
C++ code, anything that looks like this:

this->frame.lexFromMextex[1].account[UGLY_CONSTANT]++.EXTRACT_NUMBER(2);

For the love of pete, rebind a few things so it looks more sensible. (The
compiler has to anyhow in compiled languages like C++...)

In particular, take the opportunity to do something meaningful if
possible. Maybe "this->frame.lexFromMextex" is really the
"billingFrameIterator" or something. (You'd probably abbreviate Iterator
to It, but still...)




More information about the Python-list mailing list