getting attributes and methods of class without creating object

shuvro shuvro05 at gmail.com
Mon May 17 23:52:01 EDT 2010


Suppose I have a class like this -

class myClass(object):

    def __init__(self):
        self.a = 10
        self.b = 20

    def my_method(self,var = 20):
        self.local_var = var

I want to know about its method(__init__ and my_method) and
variables(a,b, local_var) without creating the object of it. I tried
getmembers function of inspect module. But it can do this with an
object of myClass as argument. Like

import inspect
var = myClass()
inspect.getmembers(var)

I have to know about this without creating the object of myClass.
Can anyone help me please?



More information about the Python-list mailing list