initialization of lists in classes
Fredrik Lundh
fredrik at pythonware.com
Fri Oct 15 04:14:26 EDT 1999
Balint Aradi <ab007 at hszk.bme.hu> wrote:
> I don't understand the mechanism behind that. Why is b.list initialized
> with the value of a.list? (Or why isn't b.float initialized with the value
> of a.float?) I'm quite a newbie in Python, so this was probably a stupid
> question, but can anyone explain that to me?
and to give you some additional clues, look
carefully at the following two statements:
self.list.append(1,2)
self.float = self.float + 2.0
they're doing two entirely different things.
can you figure out how they differ? (hint:
as you've seen, one is modifying an existing
object, one is not)
</F>
coming soon:
http://www.pythonware.com/people/fredrik/librarybook.htm
More information about the Python-list
mailing list