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-October/029381.html below:

[Python-Dev] read-only properties

[Python-Dev] read-only properties [Python-Dev] read-only propertiesDavid Abrahams dave@boost-consulting.com
08 Oct 2002 11:37:46 -0400
I was just working on some docs for Boost.Python and thought I'd write
down what happens when you try to write to a read-only property (I use
properties to expose C++ data members among other things). So:

    >>> class X(object):
    ...    def get(self): return 'x'
    ...    l = property(get)
    ...
    >>> x = X()
    >>> x.l
    'x'
    >>> x.l = 1
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    AttributeError: can't set attribute

This struck me as a very poor error message, given that mechanism in
Boost.Python v1 used to say:

    Traceback (innermost last):
      File "<string>", line 1, in ?
    AttributeError: 'l' attribute is read-only

Is it worth doing something about this?

-- 
           David Abrahams * Boost Consulting
dave@boost-consulting.com * http://www.boost-consulting.com




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