<p>Say I have an input file, and a target directory. How do I determine if the input file is on the same hard-drive (or partition) as the target directory?</p>

<p>What I want to do is the copy a file if it's on a different, but move it if it's the same. For example:</p>

<pre><code>target_directory = "/Volumes/externalDrive/something/"
input_foldername, input_filename = os.path.split(input_file)
if same_partition(input_foldername, target_directory):
    copy(input_file, target_directory)
else:
    move(input_file, target_directory)
</code></pre>

In C, you would use
```
stat()
```
and compare the
```
st_dev
```
field. In python,
```
os.stat
```
should do the same.
```
```
import os
def same_partition(f1, f2):
    return os.stat(f1).st_dev == os.stat(f2).st_dev
```
```