Python Forum
getting a full path string from a pathlib.PurePath object
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getting a full path string from a pathlib.PurePath object
#14
Python 3.6.3 | Ubuntu 17.10

In [4]: pathlib.Path('../dev/foo/baz/../baz/andre').resolve()
Out[4]: PosixPath('/home/dev/foo/baz/andre')
Python 3.5.3 | Debian 9.3
pathlib.Path('../dev/foo/baz/../baz/andre').resolve()
Error:
FileNotFoundError: [Errno 2] No such file or directory: '/dev/foo'
The answer why this happens, is here: https://docs.python.org/3/library/pathli...th.resolve
Quote:If the path doesn’t exist and strict is True, FileNotFoundError is raised. If strict is False, the path is resolved as far as possible and any remainder is appended without checking whether it exists. If an infinite loop is encountered along the resolution path, RuntimeError is raised.

New in version 3.6: The strict argument.

If you're able to install build tools on your system, you can use pyenv.
One another option could be, that you try to install this: https://pypi.python.org/pypi/pathlib2/
Or you make your own helpers for the method resolve.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: getting a full path string from a pathlib.PurePath object - by DeaD_EyE - Mar-23-2018, 08:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  -i option changes sys.path (removes leading empty string '') markanth 6 2,031 Aug-26-2022, 09:27 PM
Last Post: markanth
  Pathlib import not working chriswrcg 9 3,795 May-29-2022, 07:37 PM
Last Post: snippsat
  Convert string to path using Python 2.7 tester_V 10 6,547 Nov-20-2021, 02:20 PM
Last Post: snippsat
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,239 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  deleting an empty Dir, using pathlib.Path tester_V 9 5,925 Jul-01-2021, 01:53 PM
Last Post: Gribouillis
  Trying to pathlib instead of os.path tester_V 4 2,525 Jun-22-2021, 04:15 AM
Last Post: tester_V
  TypeError: int() argument must be a string, a bytes-like object or a number, not 'Non Anldra12 2 5,253 May-02-2021, 03:45 PM
Last Post: Anldra12
  pathlib destpath.exists() true even file does not exist NaN 9 4,744 Dec-01-2020, 12:43 PM
Last Post: NaN
  How to convert a string "<... object at POINTER>" to an object? mandaxyz 5 3,710 Aug-08-2020, 10:44 PM
Last Post: mandaxyz
  C-API for Python 3 - Get String from Object mga010 2 3,649 Jun-23-2020, 04:32 PM
Last Post: mga010

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020