<html><head></head><body>Instead, though, you'd do:<br>
<br>
f = (Path(_file__) / 'app.conf').open()<br>
<br>
<a href="https://docs.python.org/3/library/pathlib.html#pathlib.Path.open">https://docs.python.org/3/library/pathlib.html#pathlib.Path.open</a> <br>
<br><br><div class="gmail_quote">"Juancarlo Añez" <apalala@gmail.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr"><div>On a related topic...<br /></div><div><br />What's missing in Python 3.4, is that most modules with functions or methods that take file names or file paths as parameters are not pathlib-aware, so a mandatory str(mypahtlibpath) is required.<br />

<br /></div>For example, you cannot do:<br /><br /><div style="margin-left:40px">f = open(Path(_file__) / 'app.conf')<br /><br /></div>It will fail.<br /><div><div><div><br /></div><div>But pathlib as part of the standard lib is new, so it's OK. <br />

<br />It will take time how know where in the module dependency hierarchy it should belong.<br /><br /></div><div>Cheers,<br /></div><div><br /></div></div></div></div><div class="gmail_extra"><br /><br /><div class="gmail_quote">On Thu, Jul 24, 2014 at 5:19 PM, Terry Reedy <span dir="ltr"><<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a>></span> wrote:<br />

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 7/24/2014 11:30 AM, Wolfgang Maier wrote:<br />
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 24.07.2014 17:21, Juancarlo Añez wrote:<br />
</blockquote>
<br />
</div><div class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Better yet, use the pathlib module.<br />
</blockquote></blockquote>
<br /></div>
Thank for the reminder. I took a better look at it.<div class=""><br />
<br />
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
As it stands, the pathlib module is only provisional plus,<br />
</blockquote>
<br /></div>
'Provisional' means that there *could* be a few api changes that would break code. The module is not going away.<div class=""><br />
<br />
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
IMO, kind of overkill for a simple task like that.<br />
</blockquote>
<br /></div>
Overkill?<br />
<br />
import pathlib as path<br />
import os.path as path<br />
<br />
are equally easy<br />
<br />
The 'simple task' combines joining, normalizing, and 'absoluting'. pathlib.Path joins, Path.resolve normalizes and 'absolutes'. Together they combine the functions of os.path.join, os.path.abspath and os.path.normpath, with a nicer syntax, and with OS awareness.<br />


<br />
>>> path.Path('../../../Python27/<u></u>lib', 'ast.py').resolve()<br />
WindowsPath('C:/Programs/<u></u>Python27/Lib/ast.py')<br />
<br />
If one starts with a Path object, as would be typical, one can use '/' to join, as JuanCarlo mentioned.<br />
<br />
>>> base = path.Path('.')<br />
>>> (base / '../../../Python27/lib' / 'ast.py').resolve()<br />
WindowsPath('C:/Programs/<u></u>Python27/Lib/ast.py')<span class="HOEnZb"><font color="#888888"><br />
<br />
-- <br />
Terry Jan Reedy</font></span><div class="HOEnZb"><div class="h5"><br />
<br />
<br />
______________________________<u></u>_________________<br />
Python-ideas mailing list<br />
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br />
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-ideas</a><br />
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/<u></u>codeofconduct/</a></div></div></blockquote></div><br /><br clear="all" /></div></blockquote></div><br>
-- <br>
Sent from my Android phone with K-9 Mail. Please excuse my brevity.</body></html>