Newbie: problem with own module
Anna
revanna at mn.rr.com
Thu Feb 20 01:50:54 EST 2003
On Thu, 20 Feb 2003 06:09:50 +0000, Matthias Stern wrote:
> Hi! I have problems building my own modules. This is the a short version
> of the program with all functions (i show here only one) in one file:
>
> ---
> import WS
>
> def init(name):
> :
> WS.SetRunMode(1)
> :
> :
>
> :
> :
> def main():
> init(something)
> main()
> ---
>
> Now I want to put all the functions like "init()" except main() into a
> module. this look like:
>
> module "boo.py":
>
> ---
> def init(name):
> :
> WS.SetRunMode(1)
> :
> ---
>
> main program:
>
> ---
>
> import WS
> import boo
>
> def main():
> boo.init(something)
> main()
> ---
>
> When I try to run this IDLE reports:
>
> File "<snip>\boo.py", line 12, in init
> WS.SetRunMode(1)
> NameError: global name 'WS' is not defined
>
>
> I tried to set a "import WS" command into file boo.py, too. But it didn't
> help. What am I doing wrong?
Um - what's a WS? It's telling you that you never defined WS. You're
trying to do something to it, but I don't see you ever creating it... Or
am I missing something?
Anna
More information about the Python-list
mailing list