Please tell me how to execute python file in Ubuntu by double

Chris Angelico rosuav at gmail.com
Thu Dec 14 02:25:19 EST 2017


On Thu, Dec 14, 2017 at 5:44 PM, Christian Gollwitzer <auriocus at gmx.de> wrote:
> Am 14.12.17 um 02:55 schrieb Chris Angelico:
>>
>> On Thu, Dec 14, 2017 at 12:35 PM, Rick Johnson
>> <rantingrickjohnson at gmail.com> wrote:
>>>
>>> On Tuesday, December 12, 2017 at 10:42:54 PM UTC-6, eryk sun wrote:
>>> [...]
>>>>
>>>> That said, I don't see this feature as being very useful
>>>> compared to just using "open with" when I occasionally need
>>>> to open a file with a non-default program.
>>>
>>>
>>> That's the point i was trying to make, but i think it may
>>> have whoooshed over Chris's head. ;-)
>>
>>
>> No, it didn't. I just happen to have about twelve years' experience
>> with a GUI system that has this as a feature, and I found it extremely
>> helpful. It's funny how our experience colours our expectations, isn't
>> it? We just won't settle for trash once we've tasted quality.
>>
>
> I'm still unconvinced that this is much different from the Windows way
> (though I haven't used OS/2, so I'm probably missing something):
>
> Suppose, you have a file "Letter.txt" in your Documents folder on Windows.
> With standard settings, the "dumb" user (non IT expert) does not see the
> ".txt". It shows up as "Letter" with an icon for "written text". If you
> double click on it, Notepad will come up. If you right click, you'll see a
> list of programs which can open text files: Notepad, Wordpad, MS Word, any
> other editor you might have installed.
>
> How is the file extension different (to the regular user!) than a file type
> information stored in an alternate stream? Both are normally invisible and
> determine a default application as well as a number of programs which can
> open/edit the file.

If you accept that a file's name consists of the "visible part" and
the "part that affects file associations", then I suppose you could
say that Windows allows you to customize a file's associations.
However:

1) You can use this to select a file's category, but a file has to be
in precisely one category. A file cannot be both a "text file"
(associated with your editor of choice) and a "program file"
(associated with "run this program") unless you create a "text program
file" hybrid type and manually control your associations. Want to
install a new text editor? Sure. Go associate it with all of your text
types. With OS/2's type system, a program can choose on installation
to associate itself with "Plain Text", and then all text-y files will
see that program in their "Open With" sets, even if they're another
type as well (maybe "Makefile", associated with make).

2) The sort of user who would consider the file extension to be
out-of-band information is NOT going to be inventing new file
extensions and crafting associations for them. So you're basically
limited to those categories that have been set up by someone else.

> The only thing I can see from your description, apparently it was possible
> to change the default for an individual file ("Open this file always with
> Wordpad instead of Notepad") without changing th eglobal default. Is this
> the missing feature?

3) This. It's impossible to have one file in a category have a
different default; you have to change the whole category's
configuration.

4) A file's "category" also controls other things than its program
association(s), such as its icon. So if you want to invent a new file
category, you have to replicate all those other settings.

5) And the big one: you have to accept that the file name is no longer
in your control. So this fundamentally won't work with any file that
is looked for by another program, other than in the specific way of
"this is the file you clicked on". So you can't choose the editor for
an ancillary config file, you can't subcategorize your Python scripts
and still import them successfully, and you basically can't categorize
dotfiles (because ".bashrc" is of the type "bashrc", whereas ".zshrc"
is of the completely different type "zshrc").

So it's an imperfect solution even as far as it goes, and a highly
limiting way to do things. I'm sure it made good sense back when
MS-DOS file systems ruled the Windows world, and 8.3 was just the way
of things.

ChrisA



More information about the Python-list mailing list