Python newbie needs help

Ron Hudson ron.hudson at sbcglobal.net
Wed Dec 14 13:00:16 EST 2005


First let me apologize if this post offends, I am a real newbie to  
Python having only used it for about
2 days. If this is the wrong place to post newbie questions, please  
be polite.

I have the O'Reily Learning Python book and I am reading it.

Here's what I am working on..

I am trying to create something like a MUD, It will eventually evolve  
to a multi player
MUD over the network game, but for now it's just a platform for  
authoring and playing
text adventures that works like a single user MUD.

I am using a dictionary to hold the world.

I have a .py file with some def scripts(?) in it. right now it only  
has scripts to
save and load the world dictionary.

I am using "Import" to read it after I start an interactive python.  
What I need
right now is I seem to have some sort of scoping problems with the  
world dictionary.

I can read it and write it and "world<cr>" lists it out. but my def  
look(at): script
it seems it doesn't see the the "world" dictionary.

 >>> import lets
 >>> world = lets.loadworld()
 >>> world
{'wizarddescription':'A short guy wearing a robe and a pointy hat'}
 >>> lets.look('wizard')
      file "<stdin>" line ?
      file lets.py line 14 in look
         print world[at+'description']
nameError:world
 >>> at = 'wizard'
 >>> print world[at+'description']
A short guy wearing a robe and a pointy hat
 >>>

Is there a way to make 'world' global? can I do it in lets.py?

Am I going about this all wrong?

Thanks.

P.S.  Is there a way to tell python to "save my whole environment"  
and to "reload my whole environment"




More information about the Python-list mailing list