

Understanding Python metaclasses - ionelm
http://blog.ionelmc.ro/2015/02/09/understanding-python-metaclasses/

======
carapace
Metaclasses are awesome.

But the moment you put one in your codebase you have a ticking time bomb just
waiting to blow up in the face of some unsuspecting programmer who doesn't
know how they work. I've seen this in production with Django forms. Someone
had to extend a form class and couldn't do it and couldn't figure out why,
they had to ask me for help. (We wrote a little factory function to make the
form instance first and patch it after but that's damn rude to have to do.)

The point is this: there is a _HUGE_ conceptual overhead to using metaclasses,
huge. People like me will read GVR's "Killing Joke" article for kicks, because
we _like_ the feeling of our brains catching fire and exploding. But junior
devs' brains should NOT be exploding at work! (For goodness' sake, he named it
after the Python skit with the joke so funny it kills you from laughter, the
English use it on the Germans in WWII. He named it that for a reason!)

If you want to use metaclasses do it in your own home and wash your hands
afterwards.

Seriously though, please _only_ use metaclasses in your production code
(anything you want other people to use, and that isn't some experiment) if you
absolutely cannot think of a simpler, more conventional way to accomplish what
you're trying to do.

And, really, Python is so powerful and expressive I don't think you will find
yourself stumped very often.

------
ionelm
It would be very interesting to hear how the object system looks
(comparatively) in other languages.

