On Fri, Aug 7, 2020 at 5:50 PM Kazantcev Andrey <hec...@yandex.ru> wrote:
>
> Chris Angelico wrote:
>
> > Not gonna be 100% reliable and I don't think it belongs in the stdlib,
> > but might be useful.
>
> That is the problem. Sometimes libs import only methods.

I don't see that often, do you have a specific example?

Worst case, you could monkeypatch json.dumps with a version that
respects a set of defaults, prior to importing the library in
question.

import json
orig = json.dumps
def dumps(*a, **kw):
    return orig(*a, **{**json.defaults, **kw})
json.dumps = dumps
json.defaults = {}

Definitely hacky though (and you absolutely have to get your imports
in the right order) and I would much prefer not to do this. But it's
possible.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/EYLJQ3QMHB3XA6B4HJXRF4N7RHPVOAL2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to