How to display all the methods supported by an instance using dir( )..please hel
Emile van Sebille
emile at fenx.com
Fri Jun 22 09:02:19 EDT 2001
dir(t) returns the instance attributes. func is an attribute of the class
test.
class test:
def __init__(self):
self.data = 100
def func(self):
pass
t = test()
print dir(t)
print t.__class__
print dir(t.__class__)
If your class inherits behavior from other classes, you'll want to look at
the __bases__ attribute as well.
print test.__bases__
HTH,
--
Emile van Sebille
emile at fenx.com
---------
"Learn Python" <learnpython at hotmail.com> wrote in message
news:mailman.993191674.4878.python-list at python.org...
>
> hi all,
> i'm a begginer in python,
> This is what i have:
>
> class test:
> def __init__(self):
> self.data = 100
> def func(self):
> pass
> if __name__ == '__main__':
> t = test()
> dir(t) ==> i want this to list data and func
>
> But it does'nt list func :-(. What methods s'd i provide in addition so
that
> dir( ) can recognize func() which happens to be a instance method
attribute?
> I guess this s'd be possible bcos when i say
> l = [] and then dir(l), i get all the list attributes. I want the same
kind
> of behaviour for my class instance as well.
>
> thanks in advance
> karthik.
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
More information about the Python-list
mailing list