Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to make getter in python

class C(object):
    def __init__(self):
        self._x = 'Foo'

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


c = C()
print(c.x)    # Outputs "Foo"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #getter #python
ADD COMMENT
Topic
Name
8+6 =