[Tutor] default module

Kent Johnson kent37 at tds.net
Wed Jun 7 14:12:59 CEST 2006

Kermit Rose wrote:
> From: Kent Johnson <kent37 at tds.net>

>> Besides, I already have one default module saved, and it would seem
>> complicated to have more than one.
> I don't know what you mean by this, what is a default module?
> A while back in time,  I wanted to make a library of subroutines.
> Someone showed me how to tell python to declare the file a module.
> I don't remember how I did it.
> Now whenever I want to make the library available,
> in idle,
> I type 
> import factor30
> from factor30 import factor00, gcd, ksqrt   #    what ever subroutines I
> wish to have local
> I assumed that I could have only one library.
>  That why I  called it the default module.

Hi Kermit,

To make a module available for import, you just have to save it 
somewhere on your Python path. There are several ways to do this, but if 
you want to make another importable module just save it in the same 
location as factor30.py. There is no practical limit on how many modules 
you can have - just RAM and disk space limits, AFAIK. You already have 
many modules installed as part of the standard library and any 
third-party add-ons you have installed.

If you are working with a module from the interpreter and you make 
changes to the module, you have to reload it with the command
 >>> reload(factor30)

This won't work for local names (from factor30 import xx)! Just use the 
full name to access any elements of factor30, e.g. factor30.gcd. Read 
more here:


More information about the Tutor mailing list