Bare Excepts
Aahz
aahz at pythoncraft.com
Fri Jan 22 16:52:34 EST 2010
In article <80c56956-f28e-47a3-a723-3a5e3fd294b0 at j19g2000yqk.googlegroups.com>,
sjdevnull at yahoo.com <sjdevnull at yahoo.com> wrote:
>On Jan 2, 9:35=A0pm, Dave Angel <da... at ieee.org> wrote:
>>
>> In Windows, there is a way to do it. It's just not exposed to the
>> Python built-in function open(). You use the CreateFile() function,
>> with /dwCreationDisposition/ of CREATE_NEW.
>>
>> It's atomic, and fails politely if the file already exists.
>>
>> No idea if Unix has a similar functionality.
>
>It does. In Unix, you'd pass O_CREAT|O_EXCL to the open(2) system
>call (O_CREAT means create a new file, O_EXCL means exclusive mode:
>fail if the file exists already).
Thanks!
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
import antigravity
More information about the Python-list
mailing list