0

I have a string that contains {...} f-string elements that I'd like to get evaluated. And How to evaluate a variable as an f-string? tells me to do this:

>>> class A:
...     def f(self):
...             return "something"
... 
>>> a = A()
>>> a.f()
'something'
>>> f"{a.f()}"
'something'
>>> "{a.f()}".format(**vars())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'A' object has no attribute 'f()'

However, I get the error above.

finefoot
  • 9,914
  • 7
  • 59
  • 102

0 Answers0