In Python 3 one can use super() instead of super(MyClass, self), but this only works in methods that were defined inside the class. As described in Michele Simionato's article the following example does not work:
def __init__(self):
print('calling __init__')
super().__init__()
class C(object):
__init__ = __init__
if __name__ == '__main__':
c = C()
It fails because super() looks for a __class__ cell, which is not defined in this case.
Is it possible to set this cell manually after the function has been defined, or is that impossible?
Unfortunately I don't understand how cells work in this context (didn't find much documentation for that). I'm hoping for something like
__init__.__class_cell_thingy__ = C
Of course I would only use this in a situation where the class assignment is unambiguous/unique (the whole process of adding methods to a class in is automatized in my case, so it would be simple to add such a line).