[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

RE: Get Available Functions

Robert Rawlins - Think Blue

1/28/2008 5:46:00 PM

Thanks for that Tim,

I'll have a play around with these functions later today and see what
happens, hopefully it'll shed some light on this API for me.

Thanks mate, I appreciate it.

Rob

-----Original Message-----
From: Tim Chase [mailto:python.list@tim.thechases.com]
Sent: 28 January 2008 17:02
To: Robert Rawlins - Think Blue
Cc: python-list@python.org
Subject: Re: Get Available Functions

> I'm working with a python module which isn't part of the core
> Python API and it also isn't very documented or supported, is
> there any way that I can easily dump/view the available
> classes and methods within the package from within python?

Most of the time, the dir(), type() and help() functions can be
your friend:

>>> import somelib
>>> dir(somelib)
['Foo', 'thing', 'whatever']
>>> type(somelib.Foo)
<type 'Foo'>
>>> dir(somelib.Foo)
['method1', 'method2']
>>> type(somelib.thing)
<type 'str'>
>>> print somelib.thing
'I didn't expect the Spanish Inquisition!'
>>> type(somelib.whatever)
<type 'function'>
>>> help(somelib.whatever)
Help on function whatever in module somelib:

whatever(param1, param2, *args, **kwargs)
>>>


I've had a couple cases where the underlying module was written
in C (mod_python in particular...don't know if it still has this
problem) where dir() wouldn't actually tell you about the object,
but for most cases, dir() will get you pointed in the right
dir-ection. :)

-tkc