[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Paralax snow flaks: Some tipps for enhancing the performance?
Just one little correction. Technically, 'dirty' does contain a value at
that for loop, however, the interpreter believes that 'dirty' is a local
variable, separate from the globally defined one.
Whenever an assignment to a variable takes place in a function, the
interpreter assumes that it is local, even if there is a global variable
that has the same name (and even if there is references to the value that do
_not_ write to it).
Changing main() like so:
def main():
global dirty # reference the global dirty variable
frames=0
... #etc
should do the trick.
- Ian
From: Ricardo Jamin <ricardo@jaminphotography.com>
Reply-To: pygame-users@seul.org
To: pygame-users@seul.org
Subject: Re: [pygame] Paralax snow flaks: Some tipps for enhancing the
performance?
Date: 3 May 2004 12:06:26 -0000
You guessed it right.
the first time you call dirty in the main()
is in that for loop. So there\'s no value in the variable yet, not even
None.
By mischance the Interpreter splits out this:
File \"schneeflocken_dirty_rects.py\", line 69, in main
for i in dirty:
UnboundLocalError: local variable \'dirty\' referenced before assignment
Hmm, i don\'t really understand this error message. It means something like
\"want\'s to deal with a variable which hasn\'t been declared yet\" ???
Hmm, i think will toy around with this problem a little bit!
greets, Ludwig
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN Premium
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines