<div dir="ltr">It does sound like subclassing Path should be made easier.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 2, 2015 at 1:30 PM, Ryan Gonzalez <span dir="ltr"><<a href="mailto:rymg19@gmail.com" target="_blank">rymg19@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><a href="http://stackoverflow.com/a/29880095/2097780" target="_blank">http://stackoverflow.com/a/29880095/2097780</a><br></div><div><br></div><div>My favorite thing about Python is that it's so easy to be evil. ;)</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Fri, May 1, 2015 at 2:30 PM, Christophe Bal <span dir="ltr"><<a href="mailto:projetmbc@gmail.com" target="_blank">projetmbc@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>Hello.<div><br></div><div>In <a href="http://stackoverflow.com/questions/29850801/simple-subclassing-pathlib-path-does-not-work/29854141#29854141" target="_blank">this post</a>, I have noticed a problem with the following code.</div><div><br><div class="gmail_extra"><div class="gmail_quote"><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"><div dir="ltr"><div><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">from</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> pathlib </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">import</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Path</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">

</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">class</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">PPath</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Path</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">):</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">def</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> __init__</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">self</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">, <span style="white-space:inherit;margin:0px;padding:0px;border:0px">*</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">args</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">,</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px"> </span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">**</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">kwargs</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">)</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">:</span><br></span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">        super</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">().</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">__init__</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(<span style="white-space:inherit;margin:0px;padding:0px;border:0px">*</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">args</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">,</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px"> </span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">**</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px">kwargs</span><span style="white-space:inherit">)</span><br></span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
test </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">PPath</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"dir"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"test.txt"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span></code></pre></div></div></blockquote><div><div><br></div><div>This gives the following error message.</div></div><div><br></div><div> </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"><div dir="ltr"><pre style="font-size:13px;margin-top:0px;padding:5px;border:0px;overflow:auto;width:auto;max-height:600px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Traceback</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">most recent call last</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">):</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
  </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">File</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"/Users/projetmbc/test.py"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> line </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">14</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">in</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">module</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">></span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
    test </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">PPath</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"dir"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"test.txt"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
  </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">File</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"/anaconda/lib/python3.4/pathlib.py"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> line </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">907</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">in</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> __new__
    self </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> cls</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">_from_parts</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">args</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> init</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">False</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
  </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">File</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"/anaconda/lib/python3.4/pathlib.py"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> line </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">589</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">in</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> _from_parts
    drv</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> root</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> parts </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> self</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">_parse_args</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">args</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
  </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">File</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"/anaconda/lib/python3.4/pathlib.py"</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> line </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">582</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">in</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> _parse_args
    </span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">return</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> cls</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">_flavour</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">parse_parts</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">parts</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">AttributeError</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> type object </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">'PPath'</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> has no attribute </span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">'_flavour'</span></code></pre><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"></div></div></div></div></div></div></blockquote></div></div></div></div><div><br></div>This breaks the sub-classing from Python point of view. In <a href="http://stackoverflow.com/questions/29850801/simple-subclassing-pathlib-path-does-not-work/29854141#29854141" target="_blank">the post</a>, I give a hack to sub-class Path but it's a bit Unpythonic.<span><font color="#888888"><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><div dir="ltr"><b><font face="monospace" color="#000000" size="2">Christophe BAL</font></b></div><div dir="ltr"><div><b><font face="monospace" color="#666666" size="1">Enseignant de mathématiques en Lycée </font></b><b style="font-size:16.3636360168457px"><font face="monospace" color="#666666" size="1">et développeur Python amateur</font></b></div><div><font face="monospace" color="#666666" size="1"><b>---</b></font></div><div><b style="font-size:16.3636360168457px"><font face="monospace" color="#666666" size="1">French math teacher in a "Lycée" </font></b><b style="font-size:16.3636360168457px"><font face="monospace" color="#666666" size="1">and </font></b><b style="font-size:16.3636360168457px"><font face="monospace" color="#666666" size="1">Python </font></b><b style="font-size:16.3636360168457px"><font face="monospace" color="#666666" size="1">amateur developer</font></b></div></div></div></div></div></div></div></div></div>
</font></span></div>
<br></div></div>_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/rymg19%40gmail.com" target="_blank">https://mail.python.org/mailman/options/python-dev/rymg19%40gmail.com</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Ryan</div><div dir="ltr">[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.<br></div><div dir="ltr"><div><a href="http://kirbyfan64.github.io/" target="_blank">http://kirbyfan64.github.io/</a><div style="display:inline-block;width:16px;min-height:16px"> </div></div></div></div></div></div></div></div>
</font></span></div>
<br>_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" target="_blank">https://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>