I'm not certain if this is more correctly a bash issue, but it seems logical to 
at least start here.  What I hope to do is set some standard commands (whenever 
I open an interactive python shell) as are outlined in the Python.org tutorial:

2.2.4. The Interactive Startup File¶
When you use Python interactively, it is frequently handy to have some standard
commands executed every time the interpreter is started.  You can do this by
setting an environment variable named PYTHONSTARTUP to the name of a
file containing your start-up commands.  This is similar to the .profile
feature of the Unix shells.
Toward this end, I created a file that I called 'mypythonrc' and expanded the 
$PYTHONSTARTUP [bash] environmental file (in my '.bashrc' file) to include 
it--then I [re]sourced my '~/.bashrc' file to include the new entry.  The 
validity of that step shows up here:

> Fri Jan 08:lowell:Coord]:$echo $PYTHONSTARTUP
/etc/pythonrc.py:/home/lowell/bash_function/mypythonrc

The details of the file 'mypythonrc' are here:

            1 #!/usr/bin/python
            2
            3 import csv
            4 import os
            5 filename = os.environ.get('PYTHONSTARTUP')
            6 if filename and os.path.isfile(filename):
            7         execfile(filename)

The results are...well, there are none.  The expectation [is] that whenever I 
open up an interactive Python shell the two modules 'csv' and 'os' will be 
"pre"-imported, and waiting for my use.  Ain't happenin'.

So, again...is this the right venue for my question, or does it hafta be 
settled over at one of the (I guess if I hafta, I hafta) Linux forums?

>From the virtual desk of Lowell Tackett  



      
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to