News for hackers. Stuff that matters.
Re:Python 3.6.0 released by rtpg on Friday December 23, 2016 @02:49PM (#13246828)
In order to implement `f` as a plain function with same behaviour as g-strings, you would probably have to do some stack trickery to properly capture locals.

In fact, I don't think it would be possible to write such a function in the general case, because it's ambiguous what environment you would need to use.

For example:

def call(func, arg):

    a = 2

    return func(arg)
a = 1

print(call(f, "{a}"))

Does this print 1 or 2?

There are no comments on this comment yet.