You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-3Lines changed: 14 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1709,7 +1709,7 @@ class MyMetaClass(type):
1709
1709
***New() can also be called directly, usually from a new() method of a child class (**`def __new__(cls): return super().__new__(cls)`**), in which case init() is not called.**
1710
1710
1711
1711
### Metaclass Attribute
1712
-
**When class is created it checks if it has metaclass defined. If not, it recursively checks if any of his parents has it defined and eventually comes to type().**
1712
+
**Right before a class is created it checks if it has metaclass defined. If not, it recursively checks if any of his parents has it defined and eventually comes to type().**
1713
1713
1714
1714
```python
1715
1715
classMyClass(metaclass=MyMetaClass):
@@ -1721,7 +1721,13 @@ class MyClass(metaclass=MyMetaClass):
1721
1721
('abcde', 12345)
1722
1722
```
1723
1723
1724
-
#### Type diagram (str is an instance of type, ...):
1724
+
### Type Diagram
1725
+
```python
1726
+
type(MyClass) == MyMetaClass # MyClass is an instance of MyMetaClass.
1727
+
type(MyMetaClass) ==type# MyMetaClass is an instance of type.
1728
+
type(type) ==type# Type is an instance of type.
1729
+
```
1730
+
1725
1731
```text
1726
1732
+---------+-------------+
1727
1733
| Classes | Metaclasses |
@@ -1734,7 +1740,12 @@ class MyClass(metaclass=MyMetaClass):
1734
1740
+---------+-------------+
1735
1741
```
1736
1742
1737
-
#### Inheritance diagram (str is a subclass of object, ...):
1743
+
### Inheritance Diagram
1744
+
```python
1745
+
MyClass.__base__ ==object# MyClass is a subclass of object.
1746
+
object.__base__ ==None# Object is a subclass to no one.
Copy file name to clipboardExpand all lines: index.html
+10-3Lines changed: 10 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1459,14 +1459,18 @@ <h4 id="or-1">Or:</h4>
1459
1459
<li><strong>New() can also be called directly, usually from a new() method of a child class (</strong><codeclass="python hljs"><spanclass="hljs-function"><spanclass="hljs-keyword">def</span><spanclass="hljs-title">__new__</span><spanclass="hljs-params">(cls)</span>:</span><spanclass="hljs-keyword">return</span> super().__new__(cls)</code><strong>), in which case init() is not called.</strong></li>
<p><strong>When class is created it checks if it has metaclass defined. If not, it recursively checks if any of his parents has it defined and eventually comes to type().</strong></p>
1462
+
<p><strong>Right before a class is created it checks if it has metaclass defined. If not, it recursively checks if any of his parents has it defined and eventually comes to type().</strong></p>
0 commit comments