[Python-ideas] Making it easy to prepare for PEP479
Chris Angelico
rosuav at gmail.com
Tue May 19 02:22:07 CEST 2015
On Tue, May 19, 2015 at 9:06 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Steven D'Aprano wrote:
>>
>> After all, I might want to write:
>>
>> if sys.version != '3.7' and
>> read_config('config.ini')['allow_jabberwocky']:
>> from __future__ import jabberwocky
>
>
> You might want to, but I would have no qualms about
> firmly telling you that you can't. Putting try:
> in front of a future import still doesn't introduce
> any executable code before it, whereas the above does.
Yes, but imagine what happens if you want to have _two_ future imports
guarded by try/except. Either something gets completely special-cased
("try: from __future__ import foo except: pass", and no other
except/finally permitted), or you're allowed a maximum of one guarded
future import (though it might have more than one keyword in it), or
there's arbitrary code permitted in the "except" clause prior to a
future import, which would be a major problem.
ChrisA
More information about the Python-ideas
mailing list