ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved