[Python-ideas] History on proposals for Macros?

Chris Angelico rosuav at gmail.com
Sat Mar 28 23:45:18 CET 2015


On Sun, Mar 29, 2015 at 6:50 AM, Andrew Barnert
<abarnert at yahoo.com.dmarc.invalid> wrote:
> Python already has a few things you can do at runtime that affect subsequent compilation, like __future__ statements; this isn't impossible.

To be technically accurate, __future__ directives do not affect
"subsequent compilation" - they affect the compilation of the one
module they're at the top of, you can't do this:

def func1(f):
    print "Hello, world!"
    f("Haha")

from __future__ import print_function

def func2():
    func1(print)

ChrisA


More information about the Python-ideas mailing list