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

Chris Angelico rosuav at gmail.com
Tue Sep 4 18:18:57 EDT 2012


On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy <tjreedy at udel.edu> 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



More information about the Python-list mailing list