[Python-ideas] read-only attributes

K. Richard Pixley rich at noir.com
Mon Jan 3 23:18:42 CET 2011

It seems to me that one of the more common reasons for using @property 
is to create a read-only attribute.  I wonder if it would make sense to 
simply create a read-only decorator.


class Foo(object):
     _size = 4

     def size(self):
         return _size


class Foo(object):
     size = 4

This gets more interesting if decorators nest:

class Foo(object):
     __metaclass__ = abc.ABCMeta

     size = None


More information about the Python-ideas mailing list