<div dir="ltr"><br>On Wed, Apr 6, 2016 at 1:28 PM Chris Angelico <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote:<br><br> <br>> I'm not sure I entirely understand what's going on here. Your<br>> rationale is "it should be possible to use a Path as a str", and<br>> that's supported by your proposal to subclass str; but then you want<br>> to override a bunch of methods to force users to be aware that a Path<br>> is *not* a str. Why subclass only to force people to distinguish?<br> <br>> If you want to make a Path act "just a little bit" like a str, I'd<br>> expect to go the other way: don't subclass str, and add in a specific<br>> set of methods to provide str-like functionality. Or am I missing<br>> something here?<br><br>Indeed this was my thought as well. Originally (this was discussed on the python subreddit to some extent as well), my objection was that a simple program like say, left_pad.py would break depending on the implementation. This addresses that issue, but in my opinion creates even deeper problems.<div><br></div><div>Its not hard to conceive some formatting or pretty printing library that at some point contains the code</div><div><br></div><div>    def concat(user_list: List[String]) -> String:</div><div>        return functools.reduce(lambda x, y: x + y, user_list)</div><div><br></div><div>where user_list is given from some sort of user input. This change would lead to some nasty bugs, where this action will throw an error when any two adjacent args are Paths. What's worse is that type annotations actually exacerbates this issue since the objects disobey the typechecker. </div><div><br></div><div>Java subclasses aren't allowed to just unimplement a parent's methods, they shouldn't in python either. This argument seems to boil to "well a string is one valid representation of a path, so a Path is a string" but by that definition a Path is also a node in a tree, and so we should create a Tree class and have Path subclass TreeNode, so that we could find out its children and depth from the root.</div><div><br></div><div>There are so many surprising results of a change like this that I can't see a reason to do this.</div><div><br></div><div>-Josh</div></div>