Ian Shields added the comment:

Regarding last comment. I had missed the comment in documentation fo 
os.path.join "Join one or more path components intelligently. If any component 
is an absolute path, all previous components (on Windows, including the 
previous drive letter, if there was one) are thrown away, and joining 
continues". So the issue is really the behavior of os.path.join where the 
intelligence in the joining does not recognize that "~" is usually expanded to 
an absolute path. Consider the following Bash commands:
[ian@attic4 testpath]$ pwd
/home/ian/testpath
[ian@attic4 testpath]$ echo $(cd ~/testpath/..;pwd)
/home/ian
[ian@attic4 testpath]$ cd /home/ian/~
bash: cd: /home/ian/~: No such file or directory

Now consider some Python
>>> os.getcwd()
'/home/ian/testpath'
>>> os.path.join(os.getcwd(), "/home/ian")
'/home/ian'
>>> os.path.expanduser("~")
'/home/ian'
>>> os.path.join(os.getcwd(), "~")
'/home/ian/testpath/~'
>>> os.path.expanduser(os.path.abspath("~"))
'/home/ian/testpath/~'
>>> os.path.abspath(os.path.expanduser("~"))
'/home/ian'

I find the Python behavior rather odd. I cna live with it now I know about it, 
but if it is really intentional it would help to document this rather odd 
behavior somewhat better.

----------
status: pending -> open

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16877>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to