RFC: Assignment as expression (pre-PEP)
Dustan
DustanGroups at gmail.com
Sun Apr 8 16:32:46 EDT 2007
On Apr 8, 10:56 am, a... at mac.com (Alex Martelli) wrote:
> Dustan <DustanGro... at gmail.com> 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
More information about the Python-list
mailing list