PEP suggestion: Uniform way to indicate Python language version

Chris Angelico rosuav at gmail.com
Mon Aug 22 02:13:32 EDT 2016


On Mon, Aug 22, 2016 at 3:35 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Could somebody (the OP?) please explain what is the purpose of this proposal,
> what it does, how it works, and when would people use it?

My theory: A directive is actually parsed by the compiler, not
executed at run-time. So you could have a clean ImportError that says
that you need a particular version, rather than a SyntaxError because
you used "async def". But given that you can't recover from it without
the same "import mymodule2 as mymodule" trick anyway, there's not that
much difference.

ChrisA



More information about the Python-list mailing list