Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a function as a variable?

I have a function called "LoadDataClassForImageClassification" and i dont want the user to type it again and again... I tried

def LoadDataClassForImageClassification():
    print('Loading...')
    ## ML THINGS
x = LoadDataClassForImageClassification()
x()
like image 252
Coffee Guy Avatar asked May 02 '26 07:05

Coffee Guy


1 Answers

You can create a variable that it's value is the address of the function

def LoadDataClassForImageClassification():
     print('Loading...')

x = LoadDataClassForImageClassification
print(x) # <function LoadDataClassForImageClassification at 0x7f96363f11f0> # for example
x()
like image 123
dsasd Avatar answered May 03 '26 19:05

dsasd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!