Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from functools import wraps
- def self_wrapper(meth):
- @wraps(meth)
- def wrapper(self_instance):
- return meth(self_instance._i)
- return wrapper
- class B:
- def __init__(self, instance):
- self._i = instance
- @self_wrapper
- def f(self):
- return self.x
- class A:
- x = 5
- def __init__(self):
- self.b = B(self)
- a = A()
- print a.b.f()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement