The opener parameter of Python 3 open() built-in

Christian Heimes lists at cheimes.de
Mon Sep 3 09:29:05 EDT 2012


Am 03.09.2012 14:32, schrieb Marco:
> Does anyone have an example of utilisation?

The opener argument is a new 3.3 feature. For example you can use the
feature to implement exclusive creation of a file to avoid symlink attacks.

import os

def opener(file, flags):
    return os.open(file, flags | os.O_EXCL)

open("newfile", "w", opener=opener)




More information about the Python-list mailing list