Python Forum
Python Launch Options - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python Launch Options (/thread-1122.html)



Python Launch Options - Flexico - Dec-06-2016

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.


RE: Python Launch Options - metulburr - Dec-06-2016

(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.


RE: Python Launch Options - Flexico - Dec-06-2016

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.


RE: Python Launch Options - metulburr - Dec-06-2016

(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.


RE: Python Launch Options - Flexico - Dec-06-2016

Got answered here: http://www.linuxquestions.org/questions/showthread.php?s=4b698b9df27eba957e7ed19a090d0f55&p=5638499#post5638499


RE: Python Launch Options - sparkz_alot - Dec-06-2016

(Dec-06-2016, 11:18 AM)Flexico Wrote: Got answered here: http://www.linuxquestions.org/questions/showthread.php?s=4b698b9df27eba957e7ed19a090d0f55&p=5638499#post5638499

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.


RE: Python Launch Options - Flexico - Dec-07-2016

Ok, you guys here completely misunderstood what I was asking.