Daniel Kats
Daniel Kats

Reputation: 5564

Join paths in Python given operating system

Background - I am using paramiko to put files on a bunch of remote servers, running several different operating systems, and with no Python installed on the remote systems. I need to specify remote directories for where the file should be put. Because different operating systems specify paths differently, I wanted to use some module.

I wanted to use os.path.join, but that gets its configuration from my local machine. Is there any way to specify the platform in one of the os module's methods, or something similar?

EDIT: Also during ssh sessions with paramiko.

Upvotes: 3

Views: 206

Answers (1)

kenm
kenm

Reputation: 23985

Usually all of the different path modules are included, os.path is just the one for your local machine. Import ntpath if you want to do Windows path manipulation, and posixpath for Unix path manipulation.

Upvotes: 5

Related Questions