How to check if a given value is a method of a user-defined class in Python

1 Answer

0 votes
import types

class CL:
    def m1():
        print(m1())
    def m2():
        print(m2())
        
def f():
    print(f())

print(isinstance(CL().m1, types.MethodType))
print(isinstance(CL().m2, types.MethodType))

print(isinstance(f, types.MethodType))

print(isinstance(max, types.MethodType))




'''
run:

True
True
False
False

'''

 



answered Aug 29, 2021 by avibootz

Related questions

2 answers 255 views
1 answer 238 views
1 answer 197 views
3 answers 342 views
2 answers 215 views
1 answer 77 views
...