[Tutor] Newbie trying to understand modules and code reuse

RenderPipe renderpipe at speedpost.net
Thu Feb 5 14:31:24 EST 2004


Hello,

I'm having a difficult time trying to understand modules with python. I
used to write php applications and am used to including files in the
header of the document(include "file.php"). This also makes code reuse
easier. I'm under the impression modules in python work this way.

My problem is, I don't know how to write a module. I have read the
manuals and it just doesn't make sense yet. Ultimately I'd like to create
2 "include files". 
1 will be a class file that I plan to reuse throughout my application and
1 file will be a list of variables.

I tried create a file and putting it in my /python/lib directory and
importing it. Surprisingly I was able to import it but I was unable to
access the variables or methods in the file. 

Am I seeking modules incorrectly? Perhaps I should use something else for
code reuse?

I'm using WindowsXP with ActivePython

tia

Bobby


-- 
http://www.fastmail.fm - Same, same, but different




More information about the Tutor mailing list