Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically execute commands on launching python shell

Tags:

python

shell

I was wondering if there is a way to automatically run commands on entering the python shell as you would with the .bash_profile or .profile scripts with bash. I would like to automatically import some modules so I don't have to type the whole shebang everytime I hop into the shell.

Thanks,

like image 913
thepandaatemyface Avatar asked Apr 06 '10 19:04

thepandaatemyface


2 Answers

Yup you can use the PYTHONSTARTUP environment variable to do this as outlined here

like image 130
Daniel DiPaolo Avatar answered Nov 04 '22 05:11

Daniel DiPaolo


Also consider using ipython if you're doing a lot of interactive work. Your options for this kind of automation expand significantly.

like image 29
colgur Avatar answered Nov 04 '22 03:11

colgur