A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-February/020089.html below:

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

[Python-Dev] [Python 2.2 BUG] pickle/cPickle does not find __slots__ [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



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4