object oriented programming question
Daniel Nogradi
nogradi at gmail.com
Sat Dec 17 17:10:51 EST 2005
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...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051217/e28eb236/attachment.html>
More information about the Python-list
mailing list