Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'subject:Python': 0.05; 'builtin': 0.07; 'python': 0.09; '"w")': 0.09; 'path,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'cleaner': 0.16; 'complicating': 0.16; 'descriptor,': 0.16; 'directly?': 0.16; 'low-level': 0.16; 'rationale': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'string': 0.17; 'module': 0.19; 'flags': 0.22; 'example': 0.23; 'coding': 0.27; 'header:X-Complaints-To:1': 0.28; "d'aprano": 0.29; 'i/o': 0.29; 'statements': 0.29; 'steven': 0.29; 'file': 0.32; 'could': 0.32; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'especially': 0.35; 'open': 0.35; 'received:org': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'why': 0.37; 'rather': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'skip:o 20': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'telling': 0.61; 'more': 0.63; 'subject:The': 0.71; 'localized': 0.84; 'opener': 0.84; 'dennis': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: The opener parameter of Python 3 open() built-in Date: Mon, 03 Sep 2012 23:19:51 -0400 Organization: > Bestiaria Support Staff < References: <504555a5$0$29978$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-20-117.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346728806 news.xs4all.nl 6854 [2001:888:2000:d::a6]:36682 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28386 On 04 Sep 2012 01:13:09 GMT, Steven D'Aprano declaimed the following in gmane.comp.python.general: > > Why does the open builtin need this added complexity? Why not just call > os.open directly? Or for more complex openers, just call the opener > directly? > Because os.open() returns a low-level file descriptor, not a Python file object? > What is the rationale for complicating open instead of telling people to > just call their opener directly? To avoid the new syntax would mean coding the example as f = os.fdopen(os.open("newfile", flags | os.O_EXCL), "w") which does NOT look any cleaner to me... Especially not if "opener" is to be used in more than one location. Furthermore, using "opener" could allow for a localized change to affect all open statements in the module -- change file path, open for string I/O rather than file I/O, etc. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/