[Python-ideas] Opening a folder in Explorer/Nautilus/Mac-thingie

cool-RR cool-rr at cool-rr.com
Sat Jul 9 13:55:27 CEST 2011


On Sat, Jul 9, 2011 at 6:02 AM, Chris Rebert <pyideas at rebertia.com> wrote:

> On Sat, Jul 9, 2011 at 2:35 AM, cool-RR <cool-rr at cool-rr.com> wrote:
> > Hello,
> > I have the path of a certain folder. I want to open it using the default
> > folder explorer for that system. For example, if it's a Windows computer,
> I
> > want to use Explorer, if it's Linux, I want to use Nautilus or whatever
> is
> > the default there, if it's Mac, I want to use whatever Mac OS's explorer
> is
> > called.
> > I asked this on StackOverflow:
> >
> http://stackoverflow.com/questions/6631299/python-opening-a-folder-in-explorer-nautilus-mac-thingie
> > But it seems that Python doesn't offer a cross-platform way to do this.
>
> Invoking the appropriate platform-specific open-with-default-program
> command with a folder argument should work:
>
> http://stackoverflow.com/questions/434597/open-document-with-default-application-in-python
>
> If anything should be added to the std lib, I would say it should be
> this rather than a more narrow open-with-platform's-file-manager
> function.
>
> Cheers,
> Chris
>

I agree, it's better to introduce an open-with-default-program function.

It seems that `os.startfile` is supposed to do this:

http://docs.python.org/dev/library/os.html#os.startfile

But it's only available under Windows. Perhaps the solution is to implement
it under Linux and Mac as well, so we don't need to introduce a new
function?


Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110709/3856cf19/attachment.html>


More information about the Python-ideas mailing list