File: MetaClasses.rst

package info (click to toggle)
python-pytooling 8.7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 3,572 kB
  • sloc: python: 23,936; makefile: 13
file content (23 lines) | stat: -rw-r--r-- 723 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Meta-Classes
############

.. todo:: Write this tutorial

A Python meta class is a class used to construct instances of other classes.
Python has one default meta class called :class:`type`. It's possible to
write new meta classes from scratch or to derive subclasses from :class:`type`.

Meta classes are used by passing a named parameter to a class definition in
addition to a list of classes for inheritance.

.. code-block:: Python

   class Foo(Bar, metaclass=type):
     pass


.. seealso::

   * https://blog.ionelmc.ro/2015/02/09/understanding-python-metaclasses/
   * https://www.pythontutorial.net/python-oop/python-__new__/
   * https://stackoverflow.com/questions/76468665/why-does-object-new-accept-parameters