Please tell me how to execute python file in Ubuntu by double clicking on file. (Posting On Python-List Prohibited)

Rick Johnson rantingrickjohnson at gmail.com
Tue Dec 5 12:02:03 EST 2017


On Tuesday, December 5, 2017 at 2:58:44 AM UTC-6, Lawrence D'Oliveiro wrote:
> On Tuesday, December 5, 2017 at 3:39:26 AM UTC+13, Rick Johnson wrote:
> >
> > Sounds like your OS file associations are all botched-up ...
>
> Linux doesn't do "OS file associations".

True. But i'm not convinced that file associations
are really all that terrible of a thing. What do you think?

Though, Micheal Torrie did raise a valid point regarding the
pitfalls of those who rely too heavily on the X-Windows
mouse event, warning that -- paraphrasing here -- "You don't
want to invoke a python script with a double-click as you
will not maintain control of the output stream when the
program fails or quietly exits"

Fair point.

Although, on windows, at least, there is an option of using
either a ".py" file extension or a ".pyw" file extension for
your scripts, such that, when invoking the script from the
desktop enviroment (via double-click), the former will
ensure a terminal window is displayed while the latter will
suppress a terminal entirely. However, i find this design to
be woefully inadequate as a "feature". Hmm, it seems this
design is best described as: "a feature that wanted to be
great, allbeit, one that failed _miserably_".

With that in mind, a more practical implementation of
"forcing" or "suppressing" terminals via file extensions
would take the form of the following three alternatives:

    (OPTION_1): Run the script with a terminal, and autoclose
    upon fatal error or EOP. (".py")

    (OPTION_2): Run script with a terminal, but do not auto-close
    the terminal when Python chokes or the program exits,
    instead, allow the human to decide. (this will be best for
    debugging purposes) (".pydb" or ".pyt" or "pyl")

    (OPTION_3): Run the script, but suppress the terminal
    entirely. (".pyw")



More information about the Python-list mailing list