Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; 'subject:Python': 0.05; 'feature.': 0.07; 'root,': 0.07; 'files:': 0.09; 'flags,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'symlink': 0.09; 'def': 0.10; '"r",': 0.16; 'dirs,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.17; '(or': 0.18; 'example': 0.23; 'feature': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'implement': 0.32; 'file': 0.32; 'anyone': 0.33; 'to:addr:python- list': 0.33; 'christian': 0.34; 'received:org': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'received:46': 0.60; 'subject:The': 0.71; 'exclusive': 0.81; 'opener': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Serhiy Storchaka Subject: Re: The opener parameter of Python 3 open() built-in Date: Mon, 03 Sep 2012 19:06:14 +0300 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 46.185.98.182 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346688391 news.xs4all.nl 6947 [2001:888:2000:d::a6]:39483 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28363 On 03.09.12 16:29, Christian Heimes wrote: > 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. Or you can use new dir_fd argument for same reason (or for performance). for root, dirs, files, rootfd in os.fwalk(topdir): def opener(file, flags): return os.open(file, flags, dir_fd=rootfd) for name in files: with open(name, "r", opener=opener) as f: ...