Browse Source

New

pull/28/head
Jure Šorn 6 years ago
parent
commit
9b93f84ae2
1 changed files with 1 additions and 1 deletions
  1. 2
      README.md

2
README.md

@ -1477,7 +1477,7 @@ class MyMetaClass(type):
``` ```
* **New() is a class method that gets called before init(). If it returns an instance of its class, then that instance gets passed to init() as a 'self' argument.** * **New() is a class method that gets called before init(). If it returns an instance of its class, then that instance gets passed to init() as a 'self' argument.**
* **It receives the same arguments as init(), except for the first one that specifies the desired class of returned instance ('MyMetaClass' in our case).** * **It receives the same arguments as init(), except for the first one that specifies the desired class of returned instance ('MyMetaClass' in our case).**
* **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.**
* **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.**
### Metaclass Attribute ### Metaclass Attribute
**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.** **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.**

Loading…
Cancel
Save