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

Andrei Kulakov ak@silmarill.org
Tue, 25 Sep 2001 19:51:46 -0400


On Tue, Sep 25, 2001 at 04:10:07PM -0700, Danny Yoo wrote:
> 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.

Let's say your username is pan. Your home dir is then /home/pan/.
First, you should make a dir for your modules:
$ cd
$ mkdir .my_modules

Now you have to edit your .bashrc file:
$ pico .bashrc
(or .cshrc)

I'm not exactly sure if the format for .cshrc is the same, but for
.bashrc you'd have to add this line:
export PYTHONPATH=/home/pan/.my_modules

and then do:
$ source .bashrc

Next time you log in, it'll be automatically loaded.

Hope this helps,

- Andrei 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org