[Tutor] How to import my own module (fwd)

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Tue, 25 Sep 2001 16:10:07 -0700 (PDT)


Hello!

Sure, I'd be happy to show how to do this.

At the moment, I'm frantically catching up on lost time.  (I've been in
Canada the past weekend!  Very nice place.)  Let me forward this to the
rest of the tutor list first, and I'll try answering when I have more
time.

Someone else on the list may be able to help you before I get to your
question, but that's a good thing too... *grin*


---------- Forwarded message ----------
Date: Tue, 25 Sep 2001 17:43:59 -0500
From: runsun <runsun@bilbo.bio.purdue.edu>
To: Danny Yoo <dyoo@hkn.eecs.berkeley.edu>
Subject: RE: [Tutor] How to import my own module

Hi Danny,

Thx for your reply. I just started python 4 days ago and
I am trying to build some libraries for personal use. I want
to put all my modules into one folder, and have them
accessible from some other py's in different folders.

I don't know much about unix, only some basic telnet, ls
emac, ftp, ch, mkdir, cat ....... these very basic commands.
I am also capable of editing the .cshrc, .login .. files, and
source them. Could you pls show me how / where to set
the PYTHONPATH ? Or, if it's not a hassle, some example
like you mentioned will be of great help. Thx.

pan

======================================
      ~~ Be like water, be shapeless ~~
Runsun Pan, PhD, Biological Sci. Purdue Univ
Email: runsun@bilbo.bio.purdue.edu
Url : http://bilbo.bio.purdue.edu/~runsun
Tel : 765-496-4186(H), 765-494-4947 (O)
Fax : 775-665-1494 (USA) 094-656-8001 (Taiwan)
        (I can access both through my email)
======================================

 ] -----Original Message-----
 ] From: Danny Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
 ] Sent: Tuesday, September 25, 2001 5:20 PM
 ] To: runsun
 ] Cc: tutor@python.org
 ] Subject: Re: [Tutor] How to import my own module
 ]
 ]
 ] On Tue, 25 Sep 2001, runsun wrote:
 ]
 ] > How can I import my own module and use the
 ] > functions/classes/variables that are defined in
 ] > that module ?
 ] >
 ] > Should I put it in the /usr/local/bin/python folder?
 ] > Should I be a root in order to do so ? Or I can put
 ] > it in the same folder in which the calling cgi resides?
 ]
 ] It depends; if you want everyone on your system to be able to easily
 ] access your module, putting it in the site-packages directory as Ignacio
 ] suggests is a good choice.  You'll probably need to be root to move the
 ] files there.
 ]
 ] Putting the file in the same directory as the calling CGI will also work,
 ] and is probably a very good choice for CGI programs.
 ]
 ]
 ] If your module is for more personal use, you can also stuff it in a
 ] private directory, and add that directory to your PYTHONPATH environment
 ] variable.  I don't know how much experience you have in the Unix
 ] environment, but if you'd like an example, I can cook one up.  This
 ] approach may not be suitable for CGI's, but they're quite nice for one's
 ] own personal library.
 ]
 ] Good luck to you!
 ]
 ]