text: On 12/1/2009 3:35 AM, Bruno Desthuilliers wrote: > Lie Ryan a écrit : >> On 11/28/2009 3:08 PM, The Music Guy wrote: > > (snip the part about the proposed feature - which I don't like but > that's not the point) > >>> My >>> projects rely on a lot of metaclassing for the automatic generation of >>> properties and methods, which saves tremendous amounts of coding. >> >> If you use it a lot, it is likely 1) you have abused class syntax for >> what should have been a dict or 2) what you need is to override >> __getattr__/__getattribute__ and __setattr__ > > I have to totally disagree here. The way the OP uses metaprogramming is > a really common and handy solution in lots of frameworks, and > drastically reduces the need for boilerplate (and the potential for > bugs). It's *WAY* cleaner (readability, introspection, doc etc) and far > less error-prone than going the __getattr(ibute)__ / __setattr__, and > also way more efficient (from execution time POV). I won't argue with the usefulness of metaclass, I agree that metaclass is the cleanest way to implement certain things; but the main point is the OP's use of getattr/setattr while he got full control of the namespace dictionary. > Using __getattr__ and __setattr__ to emulate attributes (usually > descriptors) that can be built at class creation time is IMHO what > should be labeled as an "abuse" (at best).