metaclasses.rst 481 B

1234567891011121314151617181920
  1. Metaclasses
  2. -----------
  3. Python 3 and Python 2 syntax for metaclasses are incompatible.
  4. ``future`` provides a function (from ``jinja2/_compat.py``) called
  5. :func:`with_metaclass` that can assist with specifying metaclasses
  6. portably across Py3 and Py2. Use it like this::
  7. from future.utils import with_metaclass
  8. class BaseForm(object):
  9. pass
  10. class FormType(type):
  11. pass
  12. class Form(with_metaclass(FormType, BaseForm)):
  13. pass