I have class 'x' with member 'content' and another member  'a'  which is an instance of class '_a'. The class '_a' is callable and has a method 'func' which I would like to use to modify 'content' but I don't know how to address 'content' from the class '_a'. Is it possible?

Here is the code that I've described above:

class _a:
    def __call__(self, v):
        print v

    def func():
        """I would like to do something
        with ´content´ here"""

class x:
    def __init__(self):
        self.content = [ ]

    a = _a()


Now I would like to be able to say

inst = x()
x.a(5)
x.a.func()

where the second line prints '5' as expected, but I don't know how to make the third line change 'x.content'. I guess I'm missing some basic concepts in object oriented programming...




-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to