<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT face=Calibri size=3>Can I ¡return¢ a dictionary from an imported Python script?</FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT face=Calibri size=3>I have a utility module (NameAddress.py) <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>done using Tkinter. (For example, Name/Address City,State,Zip,Email, Phone) that I want to use as imported module. I wanted to return the values as a dictionary to the module that imported but this does not seem to work.</FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT face=Calibri size=3>This is the dictionary as printed out from the NameAddress.py by print theDict shows what I want:</FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT face=Calibri size=3>{'City': 'San Francisco', 'Name': 'Sam Spade', 'Zip': '98765', 'Address1': 'Apt. #87', 'Address2': '2345 Union Street', 'Phone': '1-415-896-9876', 'State': 'Ca.', 'Email': 'samspade@yahoo.com'}</FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT face=Calibri size=3>However the code for return in NameAddress.py <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>, I.E. <SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>return theDict<BR>gives this error when called from a testing module (Inter_module.py)<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>whose code looks like this:<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>import NameAddress<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>y = NameAddress.getName()<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>print y</FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT face=Calibri size=3>Traceback (most recent call last):</FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT size=3><FONT face=Calibri><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>File "C:\Python24\Lib\SITE-P~1\PYTHON~1\pywin\framework\scriptutils.py", line 310, in RunScript</FONT></FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT size=3><FONT face=Calibri><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>exec codeObject in __main__.__dict__</FONT></FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT size=3><FONT face=Calibri><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>File "C:\Users\B\Desktop\Inter_module.py", line 6, in ?</FONT></FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT size=3><FONT face=Calibri><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>y = NameAddress.getName()</FONT></FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT size=3><FONT face=Calibri><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>File "C:\Users\B\Desktop\NameAddress.py", line 22, in getName</FONT></FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT size=3><FONT face=Calibri><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>theDict={'Name': w2.get(), 'Address1': w4.get(), 'Address2': w6.get(),'City':w8.get()}</FONT></FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT size=3><FONT face=Calibri><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>File "C:\Python24\Lib\lib-tk\Tkinter.py", line 2303, in get</FONT></FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT size=3><FONT face=Calibri><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>return self.tk.call(self._w, 'get')</FONT></FONT></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><FONT face=Calibri size=3>TclError: invalid command name ".43065216"</FONT></DIV></td></tr></table><br>