open file in dir independently of operating system

Gerald Klix Gerald.Klix at klix.ch
Wed May 25 07:44:06 EDT 2005


Hi,
it`s

import os
f = open( os.path.join( dir , 'configuration.smo' ), 'r' )

HTH,
Gerald

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?
> 
> (I have read the manual of the module os, but I didn't see how to do
> it.)
> 
> 
> Jörg Schuster
> 

-- 
GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634




More information about the Python-list mailing list