Python 2.4 and question?

Eino Mäkitalo eino at
Tue Jan 11 15:45:03 CET 2005

I just test in Windows XP with Python 2.4

I'd like to create a file with exclusive flag.
If file exist I try to use it, if not I'd like to create it.
Python (and underlying library) works differently with/without O_EXCL 
flag. Is this okay. How I should use this.

Has somebody manual :-) ?

Eino Mäkitalo

see scenarios (1 without flag ) (2 with flag)

Scenario 1:

To create file if it's not available this works ok

 >>> os.close(aa)
 >>> os.close(aa)

Scenario 2:
But if you try to do same with O_EXCL then it does not use same logic???

 >>> os.close(aa)
Traceback (most recent call last):
   File "<string>", line 1, in <string>
OSError: [Errno 17] File exists: 'c:\\temp\\a.txt'

More information about the Python-list mailing list