[Tutor] Useing Functions

Kevin python_newbie at vedorian.com
Fri Aug 20 21:36:48 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?
----- Original Message -----
From: "Alan Gauld" <alan.gauld at blueyonder.co.uk>
To: "Kevin" <python_newbie at vedorian.com>; "Python" <tutor at python.org>
Sent: Friday, August 20, 2004 3:24 PM
Subject: Re: [Tutor] Useing Functions

> > Is it better to put everything in a def function, so that
> > instead of having to rewrite it all out over and over
> > you can just reuse the function?
> Yes, if you can reuse it put it in a function, thats largely
> what they are there for. Not only easier to use but easier to
> fix too - only one place to change...
> Then collect related functions in a file and you have a module
> that you can reuse across projects too.
> Alan G.

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.740 / Virus Database: 494 - Release Date: 8/16/04

More information about the Tutor mailing list