title: Can Python3's pathlib be used portably between Linux and Windows systems?
body: <p>I'm writing some software in Python3 intended to take a backup of a directory structure on a Windows client, and send it to a Linux server.</p>
  
  <p>The problem I'm having is how to deal with Windows and Linux file paths. I need the Windows client to create an object representing the relative path to the source file, send that relative path to the server, so the server knows which subdirectory to write the file to in the destination folder, and then send the actual data.</p>
  
  <p>Sending the actual data is not a problem, but how do I send a Windows relative path to a Linux system? I tried doing it as strings, using <code>os.path</code>, but that quickly became a mess. I'm looking at using <code>pathlib</code>.</p>
  
  <p>If I can create a path object of some sort, I can use pickle to serialize it, and send it to the server. What object would I use from pathlib to represent the path though?</p>
  
  <p><code>Path()</code> seems to create an instance of the class that works for the current filesystem (<code>PosixPath</code> or <code>WindowsPath</code>), which aren't portable. If I make a <code>WindowsPath</code> object on the Windows client, Linux won't be able to deserialize it, as you can't even instantiate a <code>WindowsPath</code> object on a Linux system.</p>
  
  <p>It looks like I could use a <code>PureWindowsPath</code> object, and send that to Linux, but how do I convert the <code>PureWindowsPath</code> object (that represents a relative path) to either a <code>PosixPath</code>, or at least a <code>PurePosixPath</code>?</p>
  
  <p>Is that possible? Or am I thinking about it all wrong?</p>