I'm Brett Slatkin and this is where I write about programming and related topics. Check out my favorite posts if you're new to this site. You can also contact me here or view my projects.

08 January 2013

TIL: Python's @property has a short-hand for setters!
class C(object):
    def __init__(self):
        self._x = None

    @property
    def x(self):
        """I'm the 'x' property."""
        return self._x

    @x.setter
    def x(self, value):
        self._x = value

    @x.deleter
    def x(self):
        del self._x
I've used Python 2.5 for so long I've been unaware of features introduced in 2008. laughcry

My question: How do you use this with Python descriptors generated by a metaclass, like the properties in NDB model classes?
© 2009-2016 Brett Slatkin