Python 2: Get network share path from drive letter

Use win32wnet from pywin32 to convert your drive letters. For example:

import win32wnet
import sys

print(win32wnet.WNetGetUniversalName(sys.argv[1], 1))

This gives me something like this when I run it:

C:\test>python get_unc.py i:\some\path
\\machine\test_share\some\path

Here's how to do it in python ≥ 3.4, with no dependencies!*

from pathlib import Path

def unc_drive(file_path):
    return str(Path(file_path).resolve())

*Note: I just found a situation in which this method fails. One of my company's network shares has permissions setup such that this method raises a PermissionError. In this case, win32wnet.WNetGetUniversalName is a suitable fallback.