Code: Select all
def __new__(cls, client, *args, **kwargs):
ns = {}
for i, attr in inspect.getmembers(client):
if i in ('__init__', '__new__', '__getattribute__', '__dict__'):
continue
ns[i] = attr
for i in cls.__dict__:
if i in ('__new__',):
continue
elif i == '__init__':
ns['_init_'] = getattr(cls, i)
continue
attr = getattr(cls, i)
ns[i] = attr
P = type(cls.__name__ + "." + client.__class__.__name__,
(Proxy2.BaseProxy,), ns)
P._client_ = client
return P(*args, **kwargs)
Code: Select all
@classmethod
Code: Select all
class SuperA:
@staticmethod
def static():
return 'static?'
class A:
def __getattribute__(self, attr):
v = object.__getattribute__(self, attr)
if hasattr(v, '__get__'):
v2 = v.__get__(None, self)
return v2
return v
A.static = getattr(SuperA, "static")
print(A.static()) # success
print(A().static()) # fail