Create a base class with a metaclass.
(meta, *bases)
| 83 | |
| 84 | |
| 85 | def with_metaclass(meta, *bases): |
| 86 | """Create a base class with a metaclass.""" |
| 87 | # This requires a bit of explanation: the basic idea is to make a |
| 88 | # dummy metaclass for one level of class instantiation that replaces |
| 89 | # itself with the actual metaclass. |
| 90 | class metaclass(type): |
| 91 | def __new__(cls, name, this_bases, d): |
| 92 | return meta(name, bases, d) |
| 93 | return type.__new__(metaclass, 'temporary_class', (), {}) |
| 94 | |
| 95 | |
| 96 | try: |