ptn wrote:
>         Traceback (most recent call last):
>           File "path.py", line 4, in <module>
>                 f = open('~/read/foo.txt')
>         IOError: [Errno 2] No such file or 
>         directory: '~/read/foo.txt' 
> [...]
> So, what's wrong here? Maybe there's something I haven't set up?

Simple: the directory "~" doesn't exist. Since you're not using a
shell (but direct file access) there is no tilde expansion, and "~"
is treated as a regular file name. If you need to get the home
directory refer to the environment variable HOME
(os.environ["HOME"]). There even may be a shorter way, please refer
to the os module docs.

Regards,


Björn

-- 
BOFH excuse #139:

UBNC (user brain not connected)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to