W
W
w0lkolak2020-06-08 23:02:02
Python
w0lkolak, 2020-06-08 23:02:02

@propety. When is fget not None?

property(fget=None, fset=None, fdel=None, doc=None)

If I see this:
class C(object):
    def getx(self): return self.__x
    def setx(self, value): self.__x = value
    def delx(self): del self.__x
    x = property(getx, setx, delx, "I'm the 'x' property.")

then everything is clear. But then, for me, everything is not clear:
class C:
    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


Python that, immediately runs through the entire class object in search of methods, which he then spreads on fget, fset, so that they are not None?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question