Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
os.path.join
#1
This has me confused as to why it does not work:
import os

PARENT_DIR = '/Volumes/Sidekick/SEER/Trip'
SOURCE_DIR = '/data/source'

# first do as concatenation and show result

OUT_DIR = PARENT_DIR + SOURCE_DIR
Print(OUT_DIR) 
Output:
>> /Volumes/Sidekick/SEER/Trip/data/source <<
# Now, do using os.path.join and show result
OUT1_DIR = os.path.join(PARENT_DIR, SOURCE_DIR)
Print(OUT1_DIR)
Output:
>> /data/source <<
Anyone have any ideas on what is happening?

TNX
Larz60+ write Nov-07-2020, 08:49 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Fixed this time. Please use going forward.
Reply


Messages In This Thread
os.path.join - by qmfoam - Nov-07-2020, 06:06 PM
RE: os.path.join - by bowlofred - Nov-07-2020, 06:14 PM
RE: os.path.join - by qmfoam - Nov-08-2020, 04:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  os.path.join() 'NoneType' confusion gowb0w 11 1,418 Sep-22-2023, 11:13 PM
Last Post: deanhystad
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,148 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  os.path.join - errors out tester_V 4 2,626 Nov-29-2020, 08:57 AM
Last Post: DeaD_EyE
  The difference between os.path.join( and os.sep.join( Pedroski55 2 9,309 Nov-17-2020, 08:38 AM
Last Post: Pedroski55
  SQL select join operation in python(Select.. join) pradeepkumarbe 1 2,203 Feb-14-2019, 08:34 PM
Last Post: woooee
  .pth file does not show up in sys.path when configuring path. arjunsingh2908 2 5,668 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