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 364 views
1 answer 317 views
1 answer 269 views
3 answers 470 views
2 answers 316 views
1 answer 173 views
...