gettin a list of functions?
Paul Simmonds
psimmo60 at hotmail.com
Mon Dec 9 10:48:45 EST 2002
>for a given scope how could i obtain a list of functions/methods.
>
>dir() is too general.
>
>either this will involve parsing the output of dir()
>
>or using the access to the compiler module that I can't figure out.
>--
>http://mail.python.org/mailman/listinfo/python-list
Try the __dict__ attribute:
>>>class myclass:
... info="Any old thing"
... description="A simple structure"
... def square(self,x):
... return x*x
...
>>>print myclass.__dict__
{'info': 'Any old thing', '__module__': '__main__', 'square': <function
square at 0x8154494>, 'description': 'A simple structure', '__doc__': None}
This will give you all the attibutes/methods except the builtins.
HTH,
Paul
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
More information about the Python-list
mailing list