[Tutor] Useing Functions
Alan Gauld
alan.gauld at blueyonder.co.uk
Fri Aug 20 22:10:50 CEST 2004
> I mande a simple module called define.py just to try it out. However
when
> put import defines in the main file I get an error: Traceback
(most recent
> call last):
> File "C:\WINDOWS\Desktop\files\python\test.py", line 5, in ?
> YesNo(x, y)
> NameError: name 'YesNo' is not defined
>
> however when I put from define import YesNo
> it works fine. Why will it not work in the ladder half?
Without seeing the code that causes the error I can only guess.
Did you remember to precede your function with the module name?
import defines
defines.YesNo(x,y)
Have a look at my modules and functions topic in my tuor it
covers how to create functions and modules and use them.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld/tutor2/
More information about the Tutor
mailing list