Python convention for passing in a file path, file name, or file object
<p>I often see Python code that accepts a variety of inputs...</p>

<p>file names</p>

<pre><code>s = Something("/Users/me/my_file.txt")
</code></pre>

<p>file paths</p>

<pre><code>s = Something("my_file.txt")
</code></pre>

<p>or file objects</p>

<pre><code>f = open("my_file.txt", "r")
s = Something(f)
</code></pre>

<p>Is there a convention to this?
As a lot of people mentioned, it depends on what <code>something()</code> is. What situations are better suited to file names vs. file objects?</p>

<p>I wonder if <a href="http://stackoverflow.com/questions/10692663/how-to-accept-file-or-path-as-arguments-to-method-in-python">this</a> SO post gives the best answer. </p>
