[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Python Question
The short answer is that the variable you passed in is a copy of a
reference. You can't change the caller's copy directly, although if
it's a data structure like a list or dictionary, you can modify it's
contents. If you're dealing with something like a string or integer,
you'll need to return any changes the caller needs to know about, so
that the caller can change it's copy.
foo = 3
def bar( a ):
return a + 1
foo = bar( foo ) # foo now equals 4
The long answer is that you're right, this isn't the right place to ask.
For simple things like this, you're best off getting a python
programming book. I like "Python, Essential Reference"
Cheers,
-Jasper
Geekius Maximus wrote:
I have a general Python language question. I know this is the pygame
board, but I don't know who else to ask. I'm trying to alter an
argument rect in a method - change it from a Rect to None, but the
change doesn't effect the variable in the calling function. What do I do?
------------------------------------------------------------------------
Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries
<http://us.rd.yahoo.com/mail_us/taglines/postman9/*http://us.rd.yahoo.com/evt=39666/*http://messenger.yahoo.com/>
for just 2¢/min with Yahoo! Messenger with Voice.