On the path to enlightenment, I smoked many manuals :)
In the directory 'schemes' we have some files:
'scheme.py'
'scheme_New.py'
'scheme_New2.py'
...
In file 'scheme_New.py' (It's few code for unique case) we have code:
class Scheme:
def hi(self):
print('Hi from NEW')
In file 'scheme.py' (It's Main Scheme with a lot of code) we have code:
class Scheme:
def __new__(cls):
from schemes.scheme_New import Scheme as NewScheme
return type('Scheme', (NewScheme, cls), {})
def hi(self):
print('Hi from Base Scheme')
Then i try (any other file):
from schemes.scheme import Scheme
scheme = Scheme()
scheme.hi()
And I get the error:
TypeError: hi() missing 1 required positional argument: 'self'
Why self is not passed?
I want to override the base class 'Scheme' from a file 'scheme.py' with a class with the SAME (important) name from the file 'scheme_New.py' and return it.
Please explain to me why this happens? What am I doing wrong?
It can be done differently, but I want it that way.
I really want to figure this out!
I appreciate all your help.