Tuesday 10:50 a.m.–11:20 a.m.
What Is and What Can Be: An Exploration from `type` to Metaclasses
Dustin Ingram
- Audience level:
- Intermediate
- Category:
- Python Core (language, stdlib, etc.)
Description
Most of us use `type` every day, but few can say they know it well. This talk explores `type` and along the way, reveals how it relates to `object`, `class` and more, eventually arriving at deeper understanding of metaclasses in Python.
Abstract
Most of us use type
every day, but few can say they know it well. This talk begins with the question: "Why can't we do j = object(); j.hi = 'there'
?"
type
Type in a general sense is a fundamental part of any language, but often we only need to scratch the surface of type
in everyday Python. When we look deeper, we realize that type
is a the center of nearly everything in Python!
Metaclasses
Metaclasses can easily be dismissed as being too complex to be fully understood by the average Pythonista, but this talk shows that with a better understanding of type
, metaclasses can easily be "de-mystified" and made into yet another tool in the toolbox of Python.