[Tutor] modular programming
Mon, 4 Feb 2002 15:07:37 +0100
On 0, Cameron Stoner <email@example.com> wrote:
> I have a little bit of a confusion I need clearing up.
> 1. How does Python do modules?
Basically, a file defines a module, with the same name as the file (minus
the .py). The module is executed when it is imported for the first time, and
durings its execution it defines functions etc inside it.
> 2. How do you call or pass values to modules and then back again?
You don't call modules or pass values to them. However, you can for instance
call a function in a module.
Suppose we have the following files:
print "This function just prints something"
print "This is run when the module is imported"
print "First, we import the module"
print "Now we can access things inside it, like func()"
I don't know what to add to this now. Chapter 6 of the Python tutorial
(http://www.python.org/doc/current/tut/tut.html) is about modules; maybe you
should read that, and come back with any more specific questions you have,
what exactly you don't understand.