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

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -