open file in dir independently of operating system

Kay Schluehr kay.schluehr at gmx.net
Wed May 25 08:10:51 EDT 2005


Joerg Schuster schrieb:

> Hello,
>
>
> I want to open the file 'configuration.smo' that is in directory dir.
> Yet, I don't know on which os my program is being run. On Unix I would
> say:
>
> f = open(dir + '/configuration.smo', 'r')
>
> What is the os-independent version of this line?

Did You check this out on Windows? My experience with *nix paths is
that they work.

>>> open("C:/bla.txt")
<open file 'C:/bla.txt', mode 'r' at 0x026B4A20>

Kay




More information about the Python-list mailing list