8vm4
could mention the @property shortcut for readonly attributes here:
class C(object):
@property
def x(self):
return value
turns the "x" method into a "getter" for a read-only attribute with the same name.
Note that this syntax also works for old-style classes, but the resulting attribute isn't read-only. If you assign to the attribute, you'll overwrite the property descriptor.
last updated 3 years ago by effbot #
