Because the underlying system calls don’t recognize user paths, and the file access APIs are a fairly thin wrapper over them.
Additionally, it would be fairly surprising for non-Unix users,
if (for example) fopen("~foo")
returns a “foo: no such user” error (as "~foo"
is a valid file name on, for example, Windows)…
Or, similarly, if fopen("~administrator")
returns an error like “Is a directory: C:\Documents and Settings\Administrator\”.
Finally, as commenters have noted: you’re confusing “duck typing” with “helpful shortcuts”, which are two entirely different things:
– Duck typing allows me to substitute for a duck anything which quacks like a duck.
– Helpful shortcuts allow me to substitute for a duck anything which could be made to quack like a duck.(Python does not “try to make it quack” like some other languages do).