Python Forum

Full Version: Python Launch Options
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm not sure if this is more a Python question or a Linux question, but here goes: I have a script file tied to the key combo Ctrl+Alt+P to navigate to my script folder and run Python. That part works.
#!/bin/bash
mate-terminal --working-directory="/home/flexico/Documents/Python_Scripts" --title="Python" --command python
However, I also want it to run a few lines of Python script, like import some standard libraries so I don't have to re-type them in every time. How do I do that? I tried adjusting the program like so:
#!/bin/bash
mate-terminal --working-directory="/home/flexico/Documents/Python_Scripts" --title="Python" --command "python /home/flexico/python_start.py"
But it just opens a blank Terminal window with a flashing cursor, which disappears when I click on it.
(Dec-06-2016, 02:28 AM)Flexico Wrote: [ -> ]I have a script file tied to the key combo Ctrl+Alt+P to navigate to my script folder and run Python.
What are you trying to do? Just run the script "python_start.py"? In linux all you need to do is
$ cd
$ python python_start.py
Quote:But it just opens a blank Terminal window with a flashing cursor, which disappears when I click on it.
youd have to show us what the script contains.
What I want is for the Python window to stay open so I can input further commands. All the script does is import a few modules.
(Dec-06-2016, 02:46 AM)Flexico Wrote: [ -> ]What I want is for the Python window to stay open so I can input further commands.
Then just do the Windows trick of add input at the end of the script to keep it open.
(Dec-06-2016, 11:18 AM)Flexico Wrote: [ -> ]Got answered here: http://www.linuxquestions.org/questions/...ost5638499

Your final solution in the link does not actually correspond to the question you asked here, but if your happy, we're happy.  btw, there is no "double click" to run a script in linux, that's Windows. If you have the proper "shebang" line at the beginning of you script, for example:

#!/usr/bin/env python
Note in the above example, this will invoke the default Python interpreter (in linux, usually python 2)
you simply type "./your_script.py

As metulburr pointed out, unless you add something to keep the terminal open, python will run the script and the close the terminal (unless of course, your running the script from within an existing terminal.
Ok, you guys here completely misunderstood what I was asking.