On Sat, Jul 1, 2017 at 6:11 PM, Steven D'Aprano <st...@pearwood.info> wrote:
>> - So there's then a new conditional import (e.g. in a compat package)? What
>> does this add?
>
> try:  chain
> except NameError:  from itertools import chain
>
> Two lines, if and only if you both need chain and want to support
> versions of Python older than 3.7.
>
> There's no need to import it if you aren't going to use it.
>

It'd be even simpler. If you want to support <3.7 and 3.7+, you write:

from itertools import chain

At least, I presume it isn't going to be *removed* from itertools.
Promotion to builtin shouldn't break pre-existing code, so the way to
be compatible with pre-promotion Pythons is simply to code for those
and not take advantage of the new builtin.

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to