0

I have a shortcut which runs python3 in a terminal window. I would like to add some import commands to a python script which is to be run when python starts.

How can I do this?

eg; I have xfce4-terminal -e python3 which starts a graphical terminal session with python3 running. I want to add something to this to make python3 execute a script, however I do not want python to exit at the end of the script, which is the default behaviour if a filename is given immediatly following the python3 command.

2
  • 1
    python3 -i filename? Commented Nov 25, 2017 at 16:05
  • Yep that's it thanks. I read the man page but didn't realize this was what I wanted. Commented Nov 25, 2017 at 16:13

1 Answer 1

1

See python --help. It mentions an environment variable called PYTHONSTARTUP which looks like it could help you get where you want.

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

1 Comment

This is exactly what I thought of. Here's a narrative walkthrough from google: tommygeorge.com/blog/pythonrc-files-and-python-startup

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.