[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Sticky Variables: Terrain Loading



Kris Schnee wrote:

> The problem is, the program decides that it's adding references
> to the same variable, "terrain," rather than doing what I want: adding a
> string. The result is that every entry in the "land" ends up being not
> only identical, but the same entry. Even though I "del terrain" to make
> it plain that I want to create a new variable.


This is how python works.  Objects are reused if they can be, on an
adhoc basis.  Consider:

>>> 2 is 1+1
True
>>> 22 is 21+1
True
>>> 222 is 221+1
False

There is no point deleting the terrain label.  The trouble is you're
trying to do things the wrong way. Perhaps you should explain why it
matters, and we can show you a different way to deal with that.


Douglas