The replace function init()creates a local instance wizard()and returns nothing:
def init(*args):
wizard(args, 'fire_spell')
To not touch a separate instance self.
Do not use __new__; which creates a new class. You just renamed the class studentand gave it an inefficient method __init__.
__call__, . , student, wizard :
class Spell(type):
def __call__(cls, *args, **kwargs):
if 'magic' not in kwargs and len(args) < 2:
kwargs['magic'] = 'fire_spell'
return wizard(*args, **kwargs)
student , magic, .
:
>>> student('name1')
<__main__.wizard object at 0x10f1e8198>
>>> vars(_)
{'magic': 'fire_spell', 'name': 'name1'}