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> .

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

Reply via email to