thanks guys. Three good answers, each slightly different, but giving me
good food for thought.
Obviously my example was a trivial one, but I wanted to isolate the
behaviour I'm seeing in my real app. I now have some good ideas for
moving forward!
cheers
S
--
http://mail.python.org/mailman/lis
first class. So my question is, can a method in one class change an
object in another class?
Diez and Lee have shown you two ways to do this.
If the answer is no, I suppose I could pass in the list as an argument
when I create the second class, then return the contents of the list
when I en
e contents of that list and then pass back the results to the
> first class. So my question is, can a method in one class change an
> object in another class?
>
> If the answer is no, I suppose I could pass in the list as an argument
> when I create the second class, then return the
first class. So my question is, can a method in one class change an
> object in another class?
Sure it can. But your code shows that you suffer from a fundamental
misunderstanding on how variables and values work in python. Don't be to
worried about that, it happens to quite a few peopl
Here's what I came up with:
#objtest.py
class first:
def __init__(self):
a = 'a'
self.a = a
print self.a
def update(self):
print 'initially, a is', self.a
self.a = second(self.a)
print 'afterwards, a is', self.a.call(self.a)
class secon
stion is, can a method in one class change an
object in another class?
If the answer is no, I suppose I could pass in the list as an argument
when I create the second class, then return the contents of the list
when I end the methods in that second class.
alternatively, I could make the list a g