Dan Stromberg a écrit : > On Fri, 12 Oct 2007 09:42:28 +0200, Bruno Desthuilliers wrote: > > >>>>So what? Otherwise you carry *always* the baggage of a public >>>>property and a private attribute whether you need this or not. At >>>>least for me it would be unnecessary in most cases. >>> >>>That "baggage" of carrying around "unneeded" methods is something the >>>computer carries for you - IE, no big deal in 99.99% of all cases. >> >>1/ Accessing the value of a property is not free. Accessing a plain >>attribute is much cheaper. > > > Python's current performance characteristics have no bearing on what is > good software engineering practice in general,
Neither useless complexity nor tryig to apply inappropriate idioms are good practices. (snip) > I'm not omniscient, and neither is anyone else; when one initially codes a > class, one doesn't know to what purposes it will need to be bent in the > future; using accessor methods instead of exposed attributes is > significantly more flexible for the future of your class. Please remember that Python has support for computed attributes (you do know what's a computed attribute, don't you ?), so you can turn a plain attribute into a computed one at any time without breakink the API. IOW, you don't need getters/setter a priori. -- http://mail.python.org/mailman/listinfo/python-list