Hi,
I have met the following bugs (Python version: 3.9.7). When I type the following code, it is complete fine.
class ABC:
a = 'a'
b = [f'{a}']
However, when I write this code, it gives me error. Similar error happens not only for f-string, but also for addition of integer.
class ABC:
a = 'a'
b = [f'{a}' for _ in range(1)]
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Temp/ipykernel_1384/2533654419.py", line 1, in <module>
class ABC:
File "C:\Users\user\AppData\Local\Temp/ipykernel_1384/2533654419.py", line 3, in ABC
b = [f'{a}' for _ in range(1)]
File "C:\Users\user\AppData\Local\Temp/ipykernel_1384/2533654419.py", line 3, in <listcomp>
b = [f'{a}' for _ in range(1)]
NameError: name 'a' is not defined
Best,
Hong