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

Tim Delaney timothy.c.delaney at gmail.com
Thu Sep 6 02:52:55 EDT 2012


On 6 September 2012 16:34, Steven D'Aprano <
steve+comp.lang.python at pearwood.info> wrote:

> On Thu, 06 Sep 2012 00:34:56 +0000, Antoine Pitrou wrote:
> > Monkey-patching globals is not thread-safe: other threads will see your
>
> modification, which is risky and fragile.
>
> Isn't that assuming that you don't intend the other threads to see the
> modification?
>
> If I have two functions in my module that call "open", and I monkey-patch
> the global (module-level) name "open" to intercept that call, I don't see
> that there is more risk of breakage just because one function is called
> from a thread.
>
> Obviously monkey-patching the builtin module itself is much riskier,
> because it doesn't just effect code in my module, it affects *everything*.


It's not as though the option to monkey-patch has been taken away. But
hopefully there is now less of a need for it.

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120906/3d14be02/attachment.html>


More information about the Python-list mailing list