Friday, February 5, 2021

How to convert from unipath to pathlib

  • AttributeError: ‘PosixPath’ object has no attribute ‘child’

    pth.child(x) –> pth / x

  • AttributeError: ‘PosixPath’ object has no attribute ‘write_file’

    pth.write_file(x) –> pth.write_text(x)

  • AttributeError: ‘PosixPath’ object has no attribute ‘lower’

    pth.lower(x) –> str(pth).lower(x)

    In general, unipath.Path objects had the feature (or the non-feature) to behave like strings.