Coffee Guy
Coffee Guy

Reputation: 155

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()

Upvotes: 3

Views: 58

Answers (1)

dsasd
dsasd

Reputation: 222

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()

Upvotes: 8

Related Questions