[Python-ideas] Making it easy to prepare for PEP479
Steven D'Aprano
steve at pearwood.info
Tue May 19 03:17:36 CEST 2015
On Tue, May 19, 2015 at 11:06:03AM +1200, Greg Ewing 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.
"Set up a try...except block" is not executable? Then how does it, um,
you know, set up the try...except block? :-)
"try" compiles to executable code. If you don't believe me:
def a():
spam
def b():
try: spam
except: pass
from dis import dis
dis(a)
dis(b)
and take note of the SETUP_EXCEPT byte-code.
In any case, I think that neither of us wants to change the rules about
what can precede a __future__ import, so hopefully the point is moot.
--
Steve
More information about the Python-ideas
mailing list