Re: [Tutor] default module

2006-06-07 Thread Kent Johnson
Kermit Rose wrote:
> From: Kent Johnson <[EMAIL PROTECTED]>

>> 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:
http://www.python.org/doc/faq/programming/#when-i-edit-an-imported-module-and-reimport-it-the-changes-don-t-show-up-why-does-this-happen

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] default module

2006-06-07 Thread Kermit Rose
  
Message: 3
Date: Tue, 06 Jun 2006 20:59:11 -0400
From: Kent Johnson <[EMAIL PROTECTED]>
Subject: Re: [Tutor] How do I get Dos to recognize python  command?
To: Python Tutor 
 
 
>
> 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?
 
Kent
 
 
**
 
Hello Kent.
 
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.
 
Kermit  <  [EMAIL PROTECTED]  >
 
 
 
 
 
 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor