Chris Lasher wrote: > Is it general good practice to access and set class attributes via > methods only, or is it okay practice to directly interact with class > attributes? The professor in a class on Perl that I'm taking suggested > that directly accessing and setting class attributes was a bad idea. > Just wondering what the current preference in Python is. > I really like the simplicity of a.b = 3. I groan when put in other environments where a method call is required.
And Python has the magic method __setattr__ to intercept attribute assignment for the times where some inspection / protection / side-effect action is desired. -- Bob Gailer 510-978-4454 _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor