python - What is the best pythonic way of wrapping an object? -


i able wrap object in python. following not seem possible, know why?

class wrapper:     def wrap(self, obj):         self = obj  = list() b = wrapper().wrap(a) # can't b.append 

thank you!

try getattr python magic :

class wrapper:     def wrap(self, obj):         self.obj = obj     def __getattr__(self, name):         return getattr(self.obj, name)  = list() b = wrapper() b.wrap(a)  b.append(10) 

Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -