The property() built-in function can take up to four arguments. : Method : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Method »

 

The property() built-in function can take up to four arguments.


# Its signature is: property(fget=None, fset=None, fdel=None, doc=None)

class MyClass(object):
    def __init__(self, x):
        assert isinstance(x, int)'"x" must be an integer!'
        self.__x = ~x

    def get_x(self):
        return ~self.__x

    x = property(get_x)

inst = MyClass('foo')
inst = MyClass(10)
print 'inst.x =', inst.x
inst.x = 20



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» Method