I would like to enhance the class pathlib.Path
but the simple example above dose not work.
from pathlib import Path
class PPath(Path):
def
It's work too.
from pathlib import Path
class SystemConfigPath(type(Path())):
def __new__(cls, **kwargs):
path = cls._std_etc()
return super().__new__(cls, path, **kwargs)
@staticmethod
def _std_etc():
return '/etc'
name = SystemConfigPath()
name = name / 'apt'
print(name)
Printed:
/etc/apt
@staticmethod can be replaced by @classmethod