My favorite thing about Python is that it's so easy to be evil. ;)On Fri, May 1, 2015 at 2:30 PM, Christophe Bal <projetmbc@gmail.com> wrote:_______________________________________________Hello.In this post, I have noticed a problem with the following code.from pathlib import Path class PPath(Path): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
test = PPath("dir", "test.txt")This gives the following error message.Traceback (most recent call last): File "/Users/projetmbc/test.py", line 14, in <module> test = PPath("dir", "test.txt") File "/anaconda/lib/python3.4/pathlib.py", line 907, in __new__ self = cls._from_parts(args, init=False) File "/anaconda/lib/python3.4/pathlib.py", line 589, in _from_parts drv, root, parts = self._parse_args(args) File "/anaconda/lib/python3.4/pathlib.py", line 582, in _parse_args return cls._flavour.parse_parts(parts) AttributeError: type object 'PPath' has no attribute '_flavour'
This breaks the sub-classing from Python point of view. In the post, I give a hack to sub-class Path but it's a bit Unpythonic.Christophe BALEnseignant de mathématiques en Lycée et développeur Python amateur---French math teacher in a "Lycée" and Python amateur developer
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/rymg19%40gmail.com
--Ryan[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido%40python.org