[Q] __methods__ and __members__ special functions...
Emile van Sebille
emile at fenx.com
Tue Jul 20 09:08:29 EDT 1999
More information about the Python-list mailing list
Tue Jul 20 09:08:29 EDT 1999
- Previous message (by thread): [Q] __methods__ and __members__ special functions...
- Next message (by thread): Scientific Plotting?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Olivier, It looks like dir(a.__class__) returns the methods available to your instance, although you may want to iterate through a.__class__.__bases__ if available as well. -- Emile van Sebille emile at fenx.com ------------------- Olivier Deckmyn <olivier.deckmyn at mail.dotcom.fr> wrote in message news:7n1n7c$7ao$1 at feed.teaser.fr... > Hi all ! > > I want to know all the methods available to a instance. > > Here is a copy of the official FAQ : > """ > 4.60. Why doesn't dir() work on builtin types like files and lists? > It should have -- and it does starting with Python 1.5 (currently in > development -- see Questions 1.13 and 2.10). > Using 1.4, you can find out which methods a given object supports by looking > at its __methods__ attribute: > > > >>> List = [] > >>> List.__methods__ > ['append', 'count', 'index', 'insert', 'remove', 'reverse', 'sort'] > """" > > if I make the test with [].__methods__ it works as expected. > But when I use my own object : > > class ClassA: > def __init__(self): > pass > > def myMethod(self, a) > return a*2 > > if I try __methods__ on a fresh instance : > > a=ClassA() > a.__methods__ > > this raises a NameError exception :( > > Why ? Where is __methods__ declared ? > Why does this work for any instance in the brower.py provided with pythonwin > ? > > Please help ! > > Olivier. > > > > >
- Previous message (by thread): [Q] __methods__ and __members__ special functions...
- Next message (by thread): Scientific Plotting?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list