Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'subject:Python': 0.05; 'case.': 0.05; 'dependency': 0.07; 'api': 0.09; 'builtins': 0.09; 'sep': 0.09; 'terry': 0.09; 'bug': 0.10; 'dangerous,': 0.16; 'descriptor.': 0.16; 'exposes': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "function's": 0.16; 'internals,': 0.16; 'reedy': 0.16; 'replaced.': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'module': 0.19; 'explicit': 0.22; 'this:': 0.23; 'patch': 0.24; 'idea': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'necessary.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'mind,': 0.29; 'received:209.85.210.174': 0.30; 'received :mail-iy0-f174.google.com': 0.30; 'function': 0.30; 'file': 0.32; 'comments': 0.33; 'to:addr:python-list': 0.33; 'knowledge': 0.33; 'received:google.com': 0.34; 'open': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'depends': 0.36; "didn't": 0.36; 'should': 0.36; 'too': 0.36; 'why': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'several': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40; 'most': 0.61; 'subject:The': 0.71; 'confusing': 0.84; 'opener': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=QOIF/t/vtWVCOoeAmI3JMB51geB7JEzVO+FnCHkgkFc=; b=fjNmGcFqSQ/EXG1/nvIPqb9vE+w/Skm2fWHAWlEGnJ+9QSHudODTIAPQdrewMqoD3o xJ94oESlSi6FmFt4jcVVNnBcOmkU293KYrcLBOLFcDD5wV/vMR/mlWpVsAO80xy7mRTX IWehBbLS7v9/vI9hQEWM4Z7Y+xVIdn/7xp6JymKytxJa0zp5MCHRt1k8GO4VGtPUoGIT xgEaLG3NKItiJjDiE36D9TclCwUkUuXdDosQ0c8mH+MmdzYZwwKZOYRXWel4qnNQS/B9 wcp4Zi01KBrHNWvBRm6/zwwZKSfcUZNTCBek2O6awVrrWjBJiAGzgZMsYKDicdQCKQ6m vh0A== MIME-Version: 1.0 In-Reply-To: References: <504555a5$0$29978$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 5 Sep 2012 08:18:57 +1000 Subject: Re: The opener parameter of Python 3 open() built-in From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346797140 news.xs4all.nl 6920 [2001:888:2000:d::a6]:53487 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28429 On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy wrote: > io.open depends on a function the returns an open file descriptor. opener > exposes that dependency so it can be replaced. I skimmed the bug report comments but didn't find an answer to this: Why not just monkey-patch? When a module function calls on a support function and you want to change that support function's behaviour, isn't monkey-patching the most usual? Several possibilities come to mind, but without knowledge of internals, I have no idea what's actually the case. * Patching builtins is too confusing or dangerous, and should be avoided? * You want to narrow the scope of the patch rather than do it globally? * Explicit is better than implicit? It just strikes me as something where an API change may not be necessary. ChrisA