
7 Aug
2020
7 Aug
'20
7:56 a.m.
On Fri, Aug 7, 2020 at 5:50 PM Kazantcev Andrey heckad@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