call a setter from __init__ in Python

Viewed 15026

How can I call a Python (v2.7) setter property from inside __init__? I written the following class but I dont know how to change it to make it work. I get an AttributeError: 'test' object has no attribute '_x' exception. There are a few similar questions around here but couldnt find an answer so far. The idea is when the initialiser is called to do some processing/slicing and assign the result to an attribute

class test(object):
    def __init__(self, a,b):
        self._x = self.x(a,b)

    @property
    def x(self):
        return self._x

    @x.setter
    def x(self, a, b):
        self._x = "Get this from {} and make a dataframe like {}".format(a,b)
1 Answers
Related