Why am I forced to os.path.expanduser in python?
<p>I'm sure it's intentional, so can someone explain the rationale for this behavior:</p>

<pre><code>Python 2.7.2 (default, Oct 13 2011, 15:27:47) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; from os.path import isdir,expanduser
&gt;&gt;&gt; isdir("~amosa/pdb")
False
&gt;&gt;&gt; isdir(expanduser("~amosa/pdb"))
True
&gt;&gt;&gt;
&gt;&gt;&gt; from os import chdir
&gt;&gt;&gt; chdir("~amosa/pdb")
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
OSError: [Errno 2] No such file or directory: '~amosa/pdb'
&gt;&gt;&gt; chdir(expanduser("~amosa/pdb"))
&gt;&gt;&gt;
</code></pre>

<p>It's really annoying since, after all, the path with a username in it <em>can</em> be resolved unambiguously... I want to write code that can handle any sort of input that a user might give me, but this behavior requires me to call expanduser on every path my code has to deal with. It also means that anywhere I print that path out for the user to see, it will be slightly less legible than what they gave me.</p>

<p>This seems inconsistent with the concept of "duck typing" in which I generalize to mean that I expect python not to whine to me unless there's actually a problem...</p>
