Descriptor puzzlement

Terry Reedy tjreedy at udel.edu
Thu Jan 8 13:55:24 EST 2004


"John Roth" <newsgroups at jhrothjr.com> wrote in message
news:vvqjj92il4o1d0 at news.supernews.com...
> Using Python 2.2.3, I create this script:
>
> [beginning of script]
>
> class AnObject(object):
>     "This might be a descriptor, but so far it doesn't seem like it"
>     def __init__(self, somedata):
>         self.it = somedata
>     def __get__(self, obj, type=None):
>         print "in get method"
>         return self.it
>     def __set__(self, obj, it):
>         print "in set method"
>         self.somedata = it

Did you mean to set self.it to match the __init__ and __get__ methods?
Or am I missing something about the esoterics of properties?

Terry J. Reedy





More information about the Python-list mailing list