On 12 October 2012 21:33, Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>Antoine Pitrou wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Fri, 12 Oct 2012 12:23:46 -0700<br>
Ethan Furman <<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Which is why I would like to see Path based on str, despite Guido's misgivings.  (Yes, I know I'm probably tilting at windmills here...)<br>
<br>
If Path is string based we get backwards compatibility with all the os and third-party tools that expect and use strings; this would allow a gentle migration to using them, as opposed to the all-or-nothing if Path is a completely new type.<br>



</blockquote>
<br>
It is not all-or-nothing since you can just call str() and it will work<br>
fine with both strings and paths.<br>
</blockquote>
<br></div>
D'oh.  You're correct, of course.<br>
<br>
What I was thinking was along the lines of:<br>
<br>
--> some_table = Path('~/addresses.dbf')<br>
--> some_table = os.path.expanduser(some_table)<br>
<br>
vs<br>
<br>
<br>
--> some_table = Path('~/addresses.dbf')<br>
--> some_table = Path(os.path.expanduser(str(<u></u>some_table)))<br>
<br>
The Path/str sandwich is ackward, as well as verbose.</blockquote><div><br></div><div>A lot of them might end up inadvertently converting back to a pure string as well, so a better comparison will in many places be: </div>


<div><br></div><blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">some_table = Path('~/addresses.dbf')<br>


some_table = Path(os.path.expanduser(some_table))<br></blockquote><div> </div>vs</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


some_table = Path('~/addresses.dbf')<br>some_table = Path(os.path.expanduser(str(<u></u>some_table)))</blockquote><div><br></div><div>which is only five characters different. I would also prefer:</div><div><br></div>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">some_table = Path('~/addresses.dbf')<br>some_table = Path(os.path.expanduser(some_table.raw()))</blockquote>


<div><br></div><div>or some other method. It just looks nicer to me in this case. Maybe .str(), .chars() or.text().</div><div><br></div><div>Additionally, if this is too painful and too often used, we can always make an auxiliary function.</div>


<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">some_table = Path('~/addresses.dbf')<br>


some_table = some_table.str_apply(os.path.expanduser)</blockquote><div><br></div><div>Where .str_apply takes (func, *args, **kwargs) and you need to wrap the function if it takes the path at a different position. I don't particularly like this option, but it exists.</div>


<blockquote></blockquote><blockquote></blockquote><blockquote></blockquote><blockquote></blockquote></div>