Hi guys,
when developing my dedent tool, I stumbled over the following
behavior:
In dedent, I had the line
from __future__ import print_function
Later in the script, I do some
exec(the_script)
and I was surprised:
The exec() script inherited the __future__ statement!
It behaved like
On Sat, Oct 1, 2016 at 9:39 PM, Christian Tismer wrote:
> The exec() script inherited the __future__ statement!
> It behaved like the future statement were implicitly there.
>
> Is that a bug or a feature?
It's documented, but not very noisily.
https://docs.python.org/2/reference/simple_stmts.ht
On Sat, Oct 1, 2016 at 10:17 PM, Chris Angelico wrote:
> So I'd call it a feature, but possibly one that warrants a mention in
> the exec and eval docs.
To clarify: This *is* documented under __future__, but not under
exec/eval. I'm just suggesting adding another cross-reference.
ChrisA
Ah, interesting!
Thanks for the clarification. So it is really possible to write
code with an implicit future statement in it, or to switch the behavior
off.
Good to know. I will probably not use it, since I can't decide on a good
default, but getting rid of print_statement is tempting...
> http