Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Ubuntu Linux and have my python files setup so that when I double click them it opens my text editor to edit them since most of my python files are "work-in-progress." However a few of my python files are in a "finished" state and I don't plan on editing them often, just running them. Is there a way to make those files double click to run instead of edit - on an individual basis? Or a way to encapsulate them some type of container to double click?

share|improve this question

As you're using file associations to edit them I suggest when you've finished them you rename them to something else (eg. blah.pyx) and then associate .pyx with execute.

Make sure you have this at the top of each ofc:

#!/usr/bin/env python
share|improve this answer

You can write wrapper scripts like this:

filename: foobar

#! /usr/bin/env python
import foobar
foobar.main()

filename: foobar.py

#! /usr/bin/env python
....
(actual code)
....
def main():
  ...
if __name__ == '__main__':
  main()

Then chmod +x foobar. To edit doubleclick on foobar.py and to run doubleclick on foobar.

This follows the unix/linux convention that executables have no extension and the python convention that the source files have a .py extension.

share|improve this answer
    
Will work but will effectively double the number of files he has – Nanzikambe Sep 24 '13 at 1:11

Asociate the .py file, right click file.py select properties/open with, then select Other application at the bottom you see a + Use a custom command, Click and use

xterm -e python2
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .