~Python ?
Thomas A. Bryan
tbryan at python.net
Tue Dec 26 02:39:37 EST 2000
Gerson Kurz wrote:
>
> On Linux, ~ usually refers to the users homedir, but not so in Python
> (at least, in ActivePython 2.0). I found out the hard way when using a
> script that issued os.makedirs() relative to ~ - It created an actual
> directory named ~. You can have real fun if you try to deleting an
> actual directory named ~ on Linux, boy.
>
> I understand that ~ is probably handled by the shell, but if Python
> doesn't deal with it, its hard to use Python in some kinds of scripts.
> (I think Perl, Pythons ugly twin-brother, does)
Wouldn't os.environ['HOME'] be an acceptable way of handling this problem?
I'm not sure whether such a variable is available under other OSs, such as
Windows, but at least environment variables are available under Windows.
I think that '~' is a foreign concept to non-UNIX users. (ActivePython is
a Windows distribution of Python, right?)
---Tom
More information about the Python-list
mailing list