[Python-Dev] [Python 2.2 BUG] pickle/cPickle does not find slots (original) (raw)

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. PythonLabs at Zope Corporation