Does Python really follow its philosophy of "Readability counts"?
pavlovevidence at gmail.com
Mon Jan 12 00:15:29 CET 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
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
More information about the Python-list