0

How can I check whether a function is a function type in python?

I did this:

print(type(func_1))

python tells me that this is a <class 'function'>

However, when I did this:

print(type(func_1) is function)

I got a NameError NameError: name 'function' is not defined

Alice
  • 1
  • 2
  • Ideally, you wouldn't do this check at all - there are other types of callable objects in Python than functions, why would you arbitrarily prevent their use? – jasonharper Jan 19 '21 at 21:58

1 Answers1

-2

you could compare it to the type of a lambda function (same thing)

print(type(func_1) == type(lambda:None))
Hadrian
  • 917
  • 5
  • 10