In article <roy-844331.19004611012...@news.panix.com>, Roy Smith <r...@panix.com> wrote:
> In article > <34c95e04-5b3f-44bc-a5bf-498518507...@p36g2000prp.googlegroups.com>, > "Madhusudan.C.S" <madhusuda...@gmail.com> wrote: > > > 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. > > As the saying goes, "It's possible to write Fortran in any language". > > My personal habit is to "declare" all instance variables in the __init__() > method of every class. If there's no better value, I set them to None. > This isn't strictly required, but I think it makes it easier for somebody > reading the code to understand the class. I agree with you. I do exactly this. It prevents a lot of problems by giving one place to look for class variables and comments on them. Setting to None is good, too, since many times if I use one before setting a value I'll get an exception or really bad results that I can easily trace to the unset variable. > I'm not a big fan of dogmatic rules, other than the rule that says you > should make your code as easy for somebody else to understand as possible. Right. -- -- Lou Pecora -- http://mail.python.org/mailman/listinfo/python-list