Does Python really follow its philosophy of "Readability counts"?

Lou Pecora pecora at anvil.nrl.navy.mil
Tue Jan 13 00:12:19 CET 2009


In article <roy-844331.19004611012009 at news.panix.com>,
 Roy Smith <roy at panix.com> wrote:

> In article 
> <34c95e04-5b3f-44bc-a5bf-498518507131 at p36g2000prp.googlegroups.com>,
>  "Madhusudan.C.S" <madhusudancs at 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



More information about the Python-list mailing list