On Apr 8, 10:56 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > Dustan <[EMAIL PROTECTED]> wrote: > > >>> class Wrapper(object): > > def __init__(self, obj): > > self.obj = obj > > def getit(self): > > return self.obj > > def setit(self, obj): > > self.obj = obj > > return obj > > Yeah, that's substantialy the same approach I posted as a Python > Cookbook recipe almost six years ago, see > <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66061> .
Indeed, I did discover that in my copy of the Python Cookbook some time ago. Perhaps I should have noted that. > My specific use case for that recipe was when using Python to code a > "reference algorithm" found in a book, so that deep restructuring was > unwanted -- a similar but opposite case is using Python to explore > prototype algorithms that would later be recoded e.g. in C (here, too, > you don't really want to refactor the Python code to use dictionaries > "properly", so assign-and-test is handy). > > Alex -- http://mail.python.org/mailman/listinfo/python-list