[Tutor] global question
Dave Kuhlman
dkuhlman at rexx.com
Sun Aug 12 00:36:07 CEST 2007
On Sat, Aug 11, 2007 at 03:40:18PM -0600, Ara Kooser wrote:
> Hello,
>
> I am back working on a text adventure game using functions. I broke
> down the game into areas (modules) but I am having trouble getting the
> other modules to recognize the globals I have set in the main program.
>
If you want your globals available to multiple modules, then put
your "globals" in a separate module, and import that module in each
module that needs access to the globals.
##################################
# globals.py
stre = 9
con = 8
inte = 11
agl = 14
# etc
##################################
# outside1.py
import globals
def whatever():
x = globals.stre
# etc
##################################
Dave
--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
More information about the Tutor
mailing list