On Tue, Sep 13, 2016 at 9:06 PM, Daiyue Weng <daiyuew...@gmail.com> wrote: > Hi, I have the following piece of code, > > rootPath = os.path.abspath(__file__) > > rootPath = (rootPath.rsplit('\\', 1)[0]).rsplit('\\', 1)[0] > > > PyCharm inspection gave me warning on argument '\\' of the 2nd rsplit, > > Expected type 'optional[bytes]' got 'str' instead >
Well, the first thing I'd do is use os.path.split instead of rsplit :) Or alternatively, os.path.join using dot-dot. And if that's not sufficient, I'd reach for pathlib. Whichever way I do it, I would *not* mix bytes paths and str paths. ChrisA -- https://mail.python.org/mailman/listinfo/python-list