<div class="gmail_extra">Formatted and finished Rebert's solution to this issue</div><div class="gmail_extra"><br></div><div class="gmail_extra"><a href="http://bugs.python.org/issue3177" target="_blank" style>http://bugs.python.org/issue3177</a></div>

<div class="gmail_extra"><br></div><div class="gmail_extra">But the question of where to put it is still open ( shutil.open vs. shutil.launch vs. os.startfile ):</div><div class="gmail_extra"><br></div><div class="gmail_extra">

1. `shutil.open()` will break anyone that does `from shutil import *` or edits the shutil.py file and tries to use the builtin open() after the shutil.open() definition.</div><div class="gmail_extra"><br></div><div class="gmail_extra">

2. `shutil.launch()` is better than shutil.open() due to reduced breakage, but not as simple or DRY or reverse-compatible as putting it in os.startfile() in my mind. This fix just implements the functionality of os.startfile() for non-Windows OSes.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">3. `shutil.startfile()` was recommended against by a developer or two on this mailing list, but seems appropriate to me. The only upstream "breakage" for an os.startfile() location that I can think of is the failure to raise exceptions on non-Windows OSes. Any legacy (<3.0) code that relies on os.startfile() exceptions in order to detect a non-windows OS is misguided and needs re-factoring anyway, IMHO. Though their only indication of a "problem" in their code would be the successful launching of a viewer for whatever path they pointed to...</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">4. `os.launch()` anyone? Not me.<br><br><div class="gmail_quote">On Mon, Apr 23, 2012 at 6:00 PM,  <span dir="ltr"><<a href="mailto:python-ideas-request@python.org" target="_blank">python-ideas-request@python.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Python-ideas mailing list submissions to<br>
        <a href="mailto:python-ideas@python.org">python-ideas@python.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:python-ideas-request@python.org">python-ideas-request@python.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:python-ideas-owner@python.org">python-ideas-owner@python.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Python-ideas digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Anyone working on a platform-agnostic os.startfile() (Hobson Lane)<br>
   2. Re: Anyone working on a platform-agnostic os.startfile()<br>
      (Chris Rebert)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 23 Apr 2012 13:21:10 +0800<br>
From: Hobson Lane <<a href="mailto:hobsonlane@gmail.com">hobsonlane@gmail.com</a>><br>
To: <a href="mailto:python-ideas@python.org">python-ideas@python.org</a><br>
Cc: Hobson's Totalgood Aliases <<a href="mailto:knowledge@totalgood.com">knowledge@totalgood.com</a>><br>
Subject: [Python-ideas] Anyone working on a platform-agnostic<br>
        os.startfile()<br>
Message-ID:<br>
        <<a href="mailto:CACZ_DoceeafEpu9wsyG0JPuAGUay0PR91xOZSwzrVy4BGZo1nQ@mail.gmail.com">CACZ_DoceeafEpu9wsyG0JPuAGUay0PR91xOZSwzrVy4BGZo1nQ@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
There is significant interest in a cross-platform<br>
file-launcher.[1][2][3][4]  The ideal implementation would be<br>
an operating-system-agnostic interface that launches a file for editing or<br>
viewing, similar to the way os.startfile() works for Windows, but<br>
generalized to allow caller-specification of view vs. edit preference and<br>
support all registered <a href="http://os.name" target="_blank">os.name</a> operating systems, not just 'nt'.<br>
<br>
Mercurial has a mature python implementation for cross-platform launching<br>
of an editor (either GUI editor or terminal-based editor like vi).[5][6]<br>
 The python std lib os.startfile obviously works for Windows.<br>
<br>
The Mercurial functionality could be rolled into os.startfile() with<br>
additional named parameters for edit or view preference and gui or non-gui<br>
preference. Perhaps that would enable backporting belwo Python 3.x. Or is<br>
there a better place to incorporate this multi-platform file launching<br>
capability?<br>
<br>
  [1]:<br>
<a href="http://stackoverflow.com/questions/1856792/intelligently-launching-the-default-editor-from-inside-a-python-cli-program" target="_blank">http://stackoverflow.com/questions/1856792/intelligently-launching-the-default-editor-from-inside-a-python-cli-program</a><br>


  [2]:<br>
<a href="http://stackoverflow.com/questions/434597/open-document-with-default-application-in-python" target="_blank">http://stackoverflow.com/questions/434597/open-document-with-default-application-in-python</a><br>
  [3]:<br>
<a href="http://stackoverflow.com/questions/1442841/lauch-default-editor-like-webbrowser-module" target="_blank">http://stackoverflow.com/questions/1442841/lauch-default-editor-like-webbrowser-module</a><br>
  [4]:<br>
<a href="http://stackoverflow.com/questions/434597/open-document-with-default-application-in-python" target="_blank">http://stackoverflow.com/questions/434597/open-document-with-default-application-in-python</a><br>
  [5]: <a href="http://selenic.com/repo/hg-stable/file/2770d03ae49f/mercurial/ui.py" target="_blank">http://selenic.com/repo/hg-stable/file/2770d03ae49f/mercurial/ui.py</a><br>
  [6]: <a href="http://selenic.com/repo/hg-stable/file/2770d03ae49f/mercurial/util.py" target="_blank">http://selenic.com/repo/hg-stable/file/2770d03ae49f/mercurial/util.py</a><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.python.org/pipermail/python-ideas/attachments/20120423/e672411c/attachment-0001.html" target="_blank">http://mail.python.org/pipermail/python-ideas/attachments/20120423/e672411c/attachment-0001.html</a>><br>


<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Sun, 22 Apr 2012 22:57:30 -0700<br>
From: Chris Rebert <<a href="mailto:pyideas@rebertia.com">pyideas@rebertia.com</a>><br>
Cc: <a href="mailto:python-ideas@python.org">python-ideas@python.org</a><br>
Subject: Re: [Python-ideas] Anyone working on a platform-agnostic<br>
        os.startfile()<br>
Message-ID:<br>
        <CAMZYqRRiRcXGZa50ggxrRRHKjncXq2mv5=+<a href="mailto:aueAtazB76KfntQ@mail.gmail.com">aueAtazB76KfntQ@mail.gmail.com</a>><br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
On Sun, Apr 22, 2012 at 10:21 PM, Hobson Lane <<a href="mailto:hobsonlane@gmail.com">hobsonlane@gmail.com</a>> wrote:<br>
> There is significant interest in a cross-platform<br>
> file-launcher.[1][2][3][4]??The ideal implementation would be<br>
> an?operating-system-agnostic interface that launches a file for editing or<br>
> viewing, similar to the way os.startfile() works for Windows, but<br>
> generalized to allow caller-specification of view vs. edit preference and<br>
> support all registered <a href="http://os.name" target="_blank">os.name</a> operating systems, not just 'nt'.<br>
<br>
There is an existing open bug that requests such a feature:<br>
"Add shutil.open": <a href="http://bugs.python.org/issue3177" target="_blank">http://bugs.python.org/issue3177</a><br>
<br>
Cheers,<br>
Chris<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
<br>
<br>
End of Python-ideas Digest, Vol 65, Issue 43<br>
********************************************<br>
</blockquote></div><br></div>