[Python-Dev] [Python 2.2 BUG] pickle/cPickle does not find __slots__

Fred L. Drake, Jr. fdrake@acm.org
Fri, 15 Feb 2002 16:10:17 -0500


Fred L. Drake, Jr. writes:
[describing a suggested property syntax]
 > class Foo(object):
 >     property myprop:
 >         """A computed property on Foo objects."""
 > 
 >         def __get__(self):
 >             return ...

Perhaps it was obvious to everyone else, but it just occured to me
that this lends itself to inheriting descriptor types:


class ReadOnly(object):
    def __get__(self):
        raise NotImplementedError("sub-class must override this!")

    def __set__(self):
        raise AttributeError("read-only attribute")

    def __delete__(self):
        raise AttributeError("read-only attribute")


class Foo(object):
    property myprop(ReadOnly):
        def __get__(self):
            return ...



  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation