Quora Feans Quora Feans - 7 months ago 41
Python Question

Are f-strings supposed to work in Python 3.4?

Is this supposed to work in Python 3.4:

>>> a='tttt'

>>> print(f'The value of a is {a}')


You could at least emulate them if really needed

def f(string):
    # (!) Using globals is bad bad bad
    return string.format(**globals())

# Use as follows:
ans = 'SPAM'
print(f('we love {ans}'))

Or maybe some other ways, like a class with reloaded __getitem__ if you like f[...] syntax