<cory at c-riddell.com> wrote in message news:mailman.988638404.26067.python-list at python.org... > I have a file called msg.pys that contains one function: > def Message(msg): > WScript.Echo(msg) > > I have a second file foo.pys that has two lines: > from msg import Message > Message("hello") > > When I run foo.pys (under wscript.exe), it doesn't work. It pops up > a box saying "NameError: global name 'WScript' is not defined". If I > put the Message() function inside of my test.pys file, everything > works fine. > > Sorry for such a simple question, but this has had me stumped for too > long. > In fact the error *I* get is "no module name 'msg'", because the interpreter isn't looking for .pys files when it processes the import statement. When I rename it to msg.py I get the error you report. Running the test.pys file under wscript.exe, the Windows scripting engine, appears to provide an implicit import of the Wscript namespace that holds all the Microsoft scripting objects. Because msg.py[s] is imported, the Wscript name is not defined as global to the module automatically. I haven't found an easy way to get it in there, either, but I'm sure someone will know how. regards Steve
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4