[Tutor] How do I squish this bug?
Joseph Quigley
cpu.crazy at gmail.com
Mon May 9 18:57:25 CEST 2005
Traceback (most recent call last):
File "C:\Python24\saved\Geek Dictionary\jargon_file.py", line 39, in
-toplevel-
main()
File "C:\Python24\saved\Geek Dictionary\jargon_file.py", line 26, in main
lobby.lobby()
File "C:/Python24/saved/Geek Dictionary\lobby.py", line 51, in lobby
import jargon_file
File "C:\Python24\saved\Geek Dictionary\jargon_file.py", line 39, in
-toplevel-
main()
File "C:\Python24\saved\Geek Dictionary\jargon_file.py", line 26, in main
lobby.lobby()
File "C:/Python24/saved/Geek Dictionary\lobby.py", line 52, in lobby
main()
NameError: global name 'main' is not defined
Source code is here:
def lobby():
print "The Lobby"
while True:
mode = raw_input('\nLobby>> ')
if mode == "commands":
commands()
elif ((mode == "exit()") or ("exit" == mode) or ("bye" == mode)):
print"\nThanks for using the Geek Dictionary!\n"
time.sleep(2)
raise SystemExit
elif mode == "email":
print
print " ", cv.prog_email
elif mode == "cemail":
print
print " ", cv.rcn_email
elif mode == "site":
print
print " ", cv.prog_site
elif mode == "info":
print "Version: ", cv.ver
print "Created by", cv.rel_creator_nm, "( a.k.a", cv.creator, ")"
print "Hope you are enjoying the program!"
print "Thanks to whoever it was at IM 2005 for the idea!\n"
print "Johny Lane is not part of Warmouth Studios"
elif ((mode == "geeker()") or ("geeker" == mode)):
print "Loading Geeker prompt...\n"
#load the gkd prompt
gkd.commands()
gkd.geeker()
elif ((mode == "jargon()") or ("jargon" == mode)):
import jargon_file
main()
elif mode == "":
print
else:
print "Command Error! Not a recognized command: " , mode
return
and the other module is:
def main():
while True:
print """\nPlease note that you may see weird symbols while using
the console when you run
this module. There are also some bugs when changing between The Lobby and the
Jargon File twice.\n"""
print "\nThe Jargon File 4.4.7\n"
print "Type 'ls' for a list of words in the Jargon File 4.4.7 or
back() to go back to\nthe lobby. As usual, 'exit()' closes the whole program"
prompt = raw_input(">> ")
if prompt == "ls":
print """ Type Q to go back to the prompt
(TM)
/dev/null
/me"""
elif prompt == "back()":
import lobby
lobby.lobby()
elif prompt == "exit()":
raise SystemExit
elif ((prompt == "(TM)") or (prompt == "(tm)")):
print TM
elif prompt == "/dev/null":
print dev_null
elif prompt == "/me":
print backslash_me
elif prompt == "0":
print num0
elif prompt == "1TBS":
print num1TBS
main()
Why do I get the error:
NameError: global name 'main' is not defined
when switching between the two module twice (ie: type: jargon type:back()
type:jargon type:back() )?
Thanks
JQ
More information about the Tutor
mailing list