Re: Assigning to global variables from within a function
by Psymaster other posts by this author
Jul 12 2003 9:05PM messages near this date
Re: Assigning to global variables from within a function
|
Re: Assigning to global variables from within a function
Irmen de Jong <irmen@[...].nl> wrote on
Sat, 12 Jul 2003 20:42:06 GMT in comp.lang.python:
> A function that modifies a global is generally considered
> bad design (it has 'side-effects').
>
> But if you really need to do this, just add a 'global'
> statement:
>
> def change_i():
> global i
> i+=1
>
I know it is bad design, it is only to increment the score in a
game I'm writing though, nothing fancy.
Thanks for the info, it works now.
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Psymaster
Irmen de Jong
Psymaster
Tom Plunket
W Isaac Carroll
|