4 ms·
If you start using metaclasses its likely more experienced pythonista's will look down their nose at you and say "probably shouldn't have done it that way", lar
by brehaut 17y ago
If you start using metaclasses its likely more experienced pythonista's will look down their nose at you and say "probably shouldn't have done it that way", largely because they often turn out to be magic for magics sake.
I believe the rule is, if you don't know when to not use metaclasses, you shouldn't be using them at all.
- kennu 17y agoI agree. I think Django's model system is a good example of when metaclasses can help a lot. It's essentially a domain-specific language that overcomes some of Python's limitations, such as remembering the order in which class attributes were defined. I have noticed that the same sometimes applies to __getattr__ and similar Python features. You easily shoot yourself in the foot unless you are very careful. So all that stuff is best left to carefully debugged and maintained libraries, and out of everyday quickly-written application code.