I think you misunderstood me - otherwise I don't know what this email is meant to accomplish. The conversation as I see it went:
Brandt in the PEP: X is an antipattern. Andrew to Brandt: A strict flag would require us to do Y which you said is an antipattern. Me to Andrew: Y is fine, it's not an antipattern, the PEP said that X (which is different from Y) is an antipattern, which I agree with. You're confirming what I'm saying but it doesn't sound intentional, especially at the start with "Then don't do it!". On Sat, May 2, 2020 at 12:50 AM Steven D'Aprano <st...@pearwood.info> wrote: > 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 > _______________________________________________ > 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/N54HB2OTJP2TBRR5UZYBYZ4Z4JNYDYDO/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ 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/4XW27MVTSG5LPRA2CO3LGAX5MVGYJ2XO/ Code of Conduct: http://python.org/psf/codeofconduct/