On Tue, 8 Aug 2006, Tom Wilson wrote:

> could someone explain to me how the "import" function works?

Hi Tom,

Take a look at:

     http://www.python.org/doc/tut/node8.html

and see if that helps; if not, come back and please feel free to ask more 
questions about it.  In a short summary: import allows us to load 
additional "modules" into our program.  These modules are often written by 
other people, and provide a lot of interesting functions.  There are a set 
of modules that come standard with each Python distribution:

     http://www.python.org/doc/lib/

For example, if we wanted to get an approximate value for pi, we could 
find that in the 'math' module:

     http://www.python.org/doc/lib/module-math.html

and to use it, we'd use 'import' to first pull math support into our 
program:

######
import math
######

after which we can reach in and get a piece of pi:

######
print math.pi
######
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to