[EMAIL PROTECTED] wrote: > Simon Forman: > >> accessing it from a >> module (perhaps math.. math.infinity, math.epsilon, etc., just like >> math.pi and math.e.) > > It too looks acceptable. > > >> I look forward to hearing your thoughts an the subject. > > Thank you, but I am not expert enough on such topics to give you good > comments, so I keep the muzzle shut. > > Bye, > bearophile >
I've been thinking along this lines as well, but with the more general question of when should a method or attribute be included in a type or class and when shouldn't it. I think that's an important question and having some clear guidelines for that will help me to write better programs in general. A few general rules I've found to be mostly true is.. (1) If a class method does not have a reference to 'self' or an attribute or other method of self. It probably should be a function instead. This is more common than you might think because class's are also used as containers to hold a collection of functions and/or values. I think its useful to keep these collections separate from "objects". It keeps the objects simpler, and the collection of functions and values clearer. The difficulty is when you mix the two together, that's when you begin to get a cluttered class that is difficult to understand. (2) If no method of a class has a reference to an attribute, then the attribute should probably not be part of the class or type. On the flip side, the inverse of these rules does not necessarily mean something should be in the class. But maybe... (3) If an value is not useful by other class's or functions. It probably should be an attribute of the class. These are just guide lines of course, but by keeping them in mind, I do think it has helped me to abstain from writing cluttered class's. Maybe there are other guidelines like these that are helpful? Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list