On Fri, May 01, 2020 at 11:30:17PM +0200, Alex Hall wrote:
Specifically the PEP says:
Another proposed idiom, per-module shadowing of the built-in zip with some subtly different variant from itertools, is an anti-pattern that shouldn't be encouraged.
I think the PEP is saying it'd be an antipattern to shadow zip with a version that is always strict. If you want both strict and non-strict in the same file, you're in trouble.
Then don't do it! If you want both, then it is trivially easy to use both: from itertools import zip_equal zip(zip_equal(a, b), c)
But replacing zip with a zip that has an optional strict flag should be harmless.
[Aside: I still disagree *strongly* with the use of a "strict" flag here.] Indeed, that's a perfectly safe and fine use of shadowing. Python is designed to allow shadowing. Calling it an "anti-pattern" is just wrong. Yes, shadowing can be abused, or done by accident, but intentional shadowing is a useful software design pattern. For instance: if not settings['print_diagnostics']: print = lambda *args, **kw: None def main(): print('diagnostics go here') ... -- Steven