Global command doesn't seem to work...

Dwight GoldWinde Dwight at GoldWinde.com
Thu Aug 13 07:06:08 EDT 2015


Inside of Functions.py I define the function:

def subwords ():
global subwordsDL
subwordsDL = {'enjoy':['like', 'appreciate', 'love', 'savor'],
'hurt':['damage', 'suffering']}
print (subwordsDL)
Return

In my test code module, the code is:

global subwordsDL
from Functions import subwords
subwords ()
print (subwordsDL)
print (subwordsDL['enjoy'][2])

I get an error on the 4th line of this module (BTW, I tried this module with
and without the first line, reaffirming subwordsDL as global, and the
results are the same):

{'hurt': ['damage', 'suffering'], 'enjoy': ['like', 'appreciate', 'love',
'savor']}
Traceback (most recent call last):
  File "test short.py", line 4, in <module>
    print (subwordsDL)
NameError: name 'subwordsDL' is not defined


LOLŠworked on this for over an hourŠ


Please help.


BIG SMILE...


Always, Dwight









-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150813/aceeec50/attachment.html>


More information about the Python-list mailing list