Message298577
Because of the special way Path and PurePath are instantiated, they can't be inherited like a normal class. Here's an example of the issue:
>>> import pathlib
>>> class MyPath(pathlib.Path):
... pass
...
>>> p = MyPath('/home')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/pathlib.py", line 969, in __new__
self = cls._from_parts(args, init=False)
File "/usr/lib/python3.5/pathlib.py", line 651, in _from_parts
drv, root, parts = self._parse_args(args)
File "/usr/lib/python3.5/pathlib.py", line 644, in _parse_args
return cls._flavour.parse_parts(parts)
AttributeError: type object 'MyPath' has no attribute '_flavour'
A solution is to get the concrete type of Path via type(Path()) and inherit the class it yields, but it isn't pretty or intuitive. Perhaps a declaration that directs to the proper class could be added to the module.
PlatformPath = WindowsPath if os.name == 'nt' else PosixPath
PurePlatformPath = ... |
|
Date |
User |
Action |
Args |
2017-07-18 06:40:11 | sbstp | set | recipients:
+ sbstp |
2017-07-18 06:40:11 | sbstp | set | messageid: <1500360011.44.0.112020885927.issue30957@psf.upfronthosting.co.za> |
2017-07-18 06:40:11 | sbstp | link | issue30957 messages |
2017-07-18 06:40:10 | sbstp | create | |
|