I have a dictionary that each value is a lambda function with a class getter function.
class test:
def __init__(
self,
filename: str,
):
self.filename = filename
@property
def read_file(self):
return read_file(self.filename) # Return pandas dataframe
func_1 = test(filename_1)
func_2 = test(filename_2)
ret = {}
ret ["key_1"] = lambda: func_1.read_file
ret ["key_2"] = lambda: func_2.read_file
I want to call to ret with "key_1" without using ()
As I can do it if call to func.read_file
(because of @property)
The main idea is to create the dictionary without actually calling to "read_file" function
And when I call the dictionary with a specific key, only one "read_file" call happens.
df = ret ["key_2"]
But now I have to use parenthesis
df = ret ["key_2"]()