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

Re: [pygame] Python Question



On 4/30/06, Jasper <jasper@xxxxxxxx> wrote:
The short answer is that the variable you passed in is a copy of a
reference.

I think saying that a variable passed in is a "copy of a reference" is
misleading about the way python works. You can think of Python as
having 2 things, objects, and bindings of names to objects (really the
name bindings themselves are properties of call stack objects, so in a
way, everything is an object).

So when you pass something in to a function (or method), you are
passing the object that the name refers to into the function. Then in
the body of the function, the argument name is bound to the object
passed in (nothing is ever copied as part of a function call, objects
are just bound to new names in the functions call stack entry). In the
body of the function, you don't get direct access to the name bindings
of the caller at all, so without doing some crazy stuff, you can't
change the variable names that the caller uses to point to different
stuff.


The long answer is that you're right, this isn't the right place to ask.

In my opinion it's totally cool to ask questions like this here, cause
it's about using pygame and rects and all that. can't seperate the two
(language and the library)

so Geekius, I think Justin put it correctly, post code showing what it
is you are trying to accomplish and some pygamer can suggest a good
way to do what it is you want to do