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

Chris Angelico rosuav at gmail.com
Wed Dec 13 00:43:55 EST 2017


On Wed, Dec 13, 2017 at 3:41 PM, eryk sun <eryksun at gmail.com> wrote:
> On Tue, Dec 12, 2017 at 3:30 PM, Chris Angelico <rosuav at gmail.com> wrote:
>> On Wed, Dec 13, 2017 at 12:54 AM, Rick Johnson
>> <rantingrickjohnson at gmail.com> wrote:
>>> Chris Angelico wrote:
>>>
>>>> Which is why OS/2, back in the 1990s, had *multiple*
>>>> associations for any given file. You could use file types
>>>> (sadly not MIME types - this was before MIME was the one
>>>> obvious standard to use) to identify *any number* of
>>>> programs that are likely to be used with a file, and then
>>>> one of them is the global default. For any specific file,
>>>> you can change which program is its own default, and even
>>>> add specific associations for that individual file. When
>>>> you double-click, you get the default; if you right-click
>>>> and choose "Open", you could pick from the associated
>>>> programs. A good system, and one that I still haven't seen
>>>> replicated in a mainstream OS.
>>>
>>> Windows has the same features.
>>
>> It does? Show me how to specify that one file - which might have the
>> exact same name as many similar files - should be associated with a
>> different program than the one its name would normally suggest. Show
>> me how to identify multiple file types for a given file, independently
>> of its filename.
>
> AFAIK that's not currently possible in Windows -- at least not without
> writing a custom shell extension. Hypothetically, the shell could
> support something like this on NTFS drives by storing a perceived type
> (e.g. text, audio, image, video) and lists of ProgIDs (e.g. txtfile,
> mp3file, jpegfile, mpegfile) either in a file's extended attributes
> (EAs) or an alternate data stream. I think OS/2 used EAs to store file
> associations. It's too bad NT's FAT32 doesn't support EAs (unlike
> FAT16 on NT, which needed them for the OS/2 subsystem) or alternate
> data streams. So an unobtrusive, decentralized approach that works
> automatically with existing backup software isn't feasible with FAT32
> drives.

Yeah, EAs were used for custom file associations and the "use that one
as the default for this file" custom default.

But honestly, who cares about FAT32? If the means of achieving this
requires a better file system, eg NTFS or ext4, that's not much of a
cost.

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

I used to often have a text executable associated with two or three
things - "run", an editor, and maybe some ancillary tool like
CASBuild. All files of that type would be associated with the same
three targets, but for one, I might have double click do a regular
run, but for another, I might always want it to go to CASBuild. Or
perhaps a GUI application might be associated with the VX-REXX "run
script" launcher rather than the regular console. A Windows equivalent
would be to have a .py file associated normally with the regular
console, but some individual ones associated with pythonw.exe -
without renaming them to .pyw. AFAIK there is no way to do this on
Windows short of renaming the files.

ChrisA



More information about the Python-list mailing list