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
#11
(Mar-21-2018, 09:50 AM)DeaD_EyE Wrote: str(your_path.resolve())

The method resolve returns a new Path object.
Path objects have a magic method for str and bytes (__str__, __bytes__).

str(pathobject) -> returns a str of the path

see my original post.

(Mar-21-2018, 09:50 AM)DeaD_EyE Wrote: str(your_path.resolve())

The method resolve returns a new Path object.
Path objects have a magic method for str and bytes (__str__, __bytes__).

str(pathobject) -> returns a str of the path

also: resolve requires that the file exist. we need a PurePath version of that just for resolving /../. also a Path version for resovling both /../ and symlinks that gracefully ends when a non-existing directory is encountered.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
RE: getting a full path string from a pathlib.PurePath object - by Skaperen - Mar-22-2018, 03:47 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,796 May-29-2022, 07:37 PM
Last Post: snippsat
  Convert string to path using Python 2.7 tester_V 10 6,550 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,254 May-02-2021, 03:45 PM
Last Post: Anldra12
  pathlib destpath.exists() true even file does not exist NaN 9 4,745 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