function inclusion problem

Laura Creighton lac at openend.se
Tue Feb 10 19:16:31 EST 2015


In a message of Wed, 11 Feb 2015 01:06:00 +0100, Laura Creighton writes:
>In a message of Tue, 10 Feb 2015 15:38:02 -0800, vlyamtsev at gmail.com writes:
>>I defined function Fatalln in "mydef.py" and it works fine if i call it from "mydef.py", but when i try to call it from "test.py" in the same folder:
>>import mydef
>>...
>>Fatalln "my test"
>>i have NameError: name 'Fatalln' is not defined
>>I also tried include('mydef.py') with the same result...
>>What is the right syntax?
>>Thanks
>>-- 
>>https://mail.python.org/mailman/listinfo/python-list
>
>from mydef import Fatalln
>

Also, please be warned.  If you use a unix system, or a linux
system.  There are lots of problems you can get into if you
expect something named 'test' to run your code.  Because they
already have one in their shell, and that one wins, and so ...
well, test.py is safe.  But if you rename it as a script and call
it the binary file test ...

Bad and unexpected things happen.

Name it 'testme' or something like that.  Never have that problem again.
:)

Been there, done that!
Laura




More information about the Python-list mailing list