I have the following code that generates "E NameError: name 'local_func' is not defined" while class is initializing
(this is just a simplified example), what am I doing wrong?
from functools import partial
def glob_func(a, b, c, x):
return 1000 * a + 100 * b + 10 * c + x
class MyClass:
local_func = partial(glob_func, 3, 1, 4)
my_list = [local_func(num)
for num in (
40,
70,
90
)]
Note: the the below is working... why not from loop?
my_list = [local_func(40),
local_func(70),
local_func(90)]