8

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,

2 Answers 2

13

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

Sign up to request clarification or add additional context in comments.

1 Comment

I don't find that link useful today (14 years later) but a good explanation today is at witkowskibartosz.com/blog/…
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.