Normally an instance can be created with something like:
class New:
def __new__(cls, *args, **kwargs):
# placeholder
return super().__new__(cls)
def __init__(self, name):
self.name = name
>>> n=New('bob')
>>> n
<__main__.New object at 0x103483550>
What occurs behind the scenes here? For example, something like:
new_uninitialized_obj = object.__new__(New)
new_initialized_obj = new_uninitialized_obj.__init__("Bob")
The above won't work, but I'm basically just trying to see how a base type is converted via new
and then init
into the instance object. How would this actually be done?