1# test builtin callable
2
3# primitives should not be callable
4print(callable(None))
5print(callable(1))
6print(callable([]))
7print(callable("dfsd"))
8
9# modules should not be callabe
10try:
11    import usys as sys
12except ImportError:
13    import sys
14print(callable(sys))
15
16# builtins should be callable
17print(callable(callable))
18
19# lambdas should be callable
20print(callable(lambda:None))
21
22# user defined functions should be callable
23def f():
24    pass
25print(callable(f))
26
27# types should be callable, but not instances
28class A:
29    pass
30print(callable(A))
31print(callable(A()))
32
33# instances with __call__ method should be callable
34class B:
35    def __call__(self):
36        pass
37print(callable(B()))
38
39# this checks internal use of callable when extracting members from an instance
40class C:
41    def f(self):
42        return "A.f"
43class D:
44    g = C() # g is a value and is not callable
45print(callable(D().g))
46print(D().g.f())
47