Does Python really follow its philosophy of "Readability counts"?
Carl Banks
pavlovevidence at gmail.com
Sun Jan 11 18:15:29 EST 2009
On Jan 11, 3:31 pm, Chris Rebert <c... at rebertia.com> wrote:
> On Sun, Jan 11, 2009 at 1:22 PM, Madhusudan.C.S <madhusuda... at gmail.com> wrote:
> > def somemethod(self, arg1):
> > self.c = 20.22
> > d = "some local variable"
> > # do something
> > ....
> > ...
> > def somemethod2 (self, arg2):
> > self.c = "Changed the variable"
> > # do something 2
> > ...
>
> > In such situations, where the Instance variables come into existence
> > only when they are used
> > it is very difficult to track the flow of code. Its obviously not
> > possible to remember what
> > instance variable was defined where, when reading some substantial
> > amount of code and where
> > it was manipulated for that matter. It becomes so very frustrating
> > even when reading a Class's
> > code with just 6-8 methods and not more than 100-150 lines of code.
>
> That's bad coding style on the part of the code writer.
> Conditionally-existing instance variables are *evil*.
Do you mean conditionally-useful instance variables evil, or that
conditionally-useful variables are ok but it's evil for them to
conditionally-exist?
The former I don't agree with at all.
If it's the latter, I believe there is something to be said for
variables that exist when they are needed and don't when they're not.
However, I acknowledge that listing all the variables you intend to
use in __init__ is highly comforting, even if it does belie their
current uselessness.
Carl Banks
More information about the Python-list
mailing list