Python Forum
Help | How to make Dynamic Path/Address
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help | How to make Dynamic Path/Address
#4
Path has the ability to used like os.path.join:

from pathlib import Path

parent = Path(__file__).parent
car_pic = Path(parent, 'Data', 'Pics', 'Car.png')
Also os.path.absolute is not needed:


parent = Path(__file__).parent.absolute()
Functions/Methods were added since Python 3.5. I use it with Python 3.6, but I can't memorize the missing functions/methods in older versions.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: Help | How to make Dynamic Path/Address - by DeaD_EyE - Jul-14-2019, 03:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,220 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  Looking for discord bot to make loop ping for address ip tinkode 0 1,835 Jul-26-2021, 03:51 PM
Last Post: tinkode
  I code a program to solve puzzle but i can't make it more dynamic. Shahmadhur13 5 2,764 Apr-18-2020, 10:05 AM
Last Post: Shahmadhur13
  .pth file does not show up in sys.path when configuring path. arjunsingh2908 2 5,780 Jul-03-2018, 11:16 AM
Last Post: arjunsingh2908

Forum Jump:

User Panel Messages

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