Making your own Magic - Daniel Moisset
If you’ve used Django, you may have noticed that many classes like Form or Model do not behave in the normal way that your classes do…. They have this funky way or specifying its fields. They sometimes get attributes out of nowhere, like the reverse of a relation field. They have been keeping ordering of its fields from before ordered dictionaries was a thing in Python. You can configure them with this special “class Meta” thingies that seem to follow some unusual inheritance rules.
All of this uses some features of Python which are sometimes called “magic”, but as in all magic there’s usually a man behind a curtain doing something we can explain. In this talk I’ll discuss some of the Python advanced features (including some aptly called “magic methods”, metaclasses and descriptors) to give a general idea of how you can use them, with examples on how Django does.
This talk is not a tutorial (it would be longer if it tried to cover all these topics in depths), but you should leave out with some general knowledge of some Python features and where they can be used in case you want to explore deeper into them.
(Unfortunately we have no slides or video for this talk)