On Sun, Jan 11, 2009 at 1:22 PM, Madhusudan.C.S <madhusuda...@gmail.com> wrote: > I am sorry all I am not here to just blame Python. This is just an > introspection of whether > what I believe is right. Being a devotee of Python from past 2 years I > have been writing only > small apps and singing praises about Python where ever I go. I now got > a chance to read > Django's code for some reason. I have now strongly started feeling if > Python really follows its > "Readability Counts" philosophy. For example, > > class A: > a = 10 > b = "Madhu"
Those are class variables, not instance variables. There is a distinct difference. Instance variables, in contrast, are "declared" and created in the body of the __init__ method. > > 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*. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list