Example wanted for inspect module

Skip Montanaro skip at pobox.com
Tue Aug 21 21:45:44 CEST 2001


    richard> Could somebody please provide an example of how the predicate
    richard> is used (for example - to get only the functions from a
    richard> module).

How about (only lightly tested):

    import types, inspect, Tkinter

    def isfunction(obj):
        return isinstance(obj, types.FunctionType)

    print inspect.getmembers(Tkinter, isfunction)

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list