python 3.x - How do I know the type of a class variable before i create instance of it? -
some class example:
>>> import inspect >>> class test(object): def test_method(self): pass now, let's check type of varable class object:
>>> type(test.test_method) <class 'function'> nope. instance of class?
>>> test_var = test() >>> type(test_var.test_method) <class 'method'> yep, that's not want. let's try inspect module:
>>> inspect.ismethod(test_var.test_method) true >>> inspect.ismethod(test.test_method) false nope. why?
Comments
Post a Comment