Subclass `pathlib.Path` fails

后端 未结 7 1622
情歌与酒
情歌与酒 2020-12-16 10:24

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          


        
7条回答
  •  旧巷少年郎
    2020-12-16 10:41

    Here is a simple way to do things regarding to the observation made by Kevin.

    class PPath():
        def __init__(self, *args, **kwargs):
            self.path = Path(*args, **kwargs)
    

    Then I will need to use a trick so as to automatically bind all the Path's methods to my PPpath class. I think that will be funny to do.

提交回复
热议问题