my specific use case i'm trying subclass pathlib.path . want able add or override functionality, want inherit of path. path has __new__ , in has: if cls path: cls = windowspath if os.name == 'nt' else posixpath in other words, path requires passing proper class it. problem don't know how both create class , call path.__new__ cls == path . i've tried many things , each 1 gives me different problem. 1 gives me attributeerror: type object 'rpath' has no attribute '_flavour' because i'm trying override parent class. python3: class rpath(path): def __new__(cls, basedir, *args, **kwargs): return path.__new__(cls, *args, **kwargs) def __init__(self, basedir, *pathsegs): super().__init__() self.basedir = basedir def newfunction(self): print('something new') and 1 gives returns path object, , hence doesn't allow me overrides. def __new__(cls, basedir, *args, **kwargs): ...
Comments
Post a Comment