[Python-ideas] History on proposals for Macros?

Andrew Barnert abarnert at yahoo.com
Sun Mar 29 05:58:25 CEST 2015


On Mar 28, 2015, at 15:45, Chris Angelico <rosuav at gmail.com> wrote:
> 
> 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)

Except at the interactive interpreter, where you can write exactly that, and it will do exactly what you'd want/expect.



More information about the Python-ideas mailing list