user2138149
user2138149

Reputation: 16585

python3: How can I run a python script when python starts?

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.

Upvotes: 0

Views: 62

Answers (1)

Jeronimo
Jeronimo

Reputation: 2387

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

Upvotes: 1

Related Questions