Tom Holroyd (NIH/NIMH) [E] wrote:
[...]
> 
> For the C library you say "man strcpy" or "man erf" and it tells you 
> what include file to use to get the definition (function prototype). In 
> python you only get the help after you've already imported. But it was 
> and still is reasonable to have an import statement like an #include to 
> define stuff you need. If I'm looking at somebody else's code and I see 
> "linspace" or something, it would be nice to have a "man linspace" or 
> so, that tells me which module I need to import. Is there a way to 
> convert doc strings to man pages?

I don't know of any such tool, but it could be done.  I don't think it 
would solve the problem you refer to, though, which I understand as 
wanting to know where a given function actually comes from.  One of the 
problems with creating a huge number of man pages for this is that 
function names may be duplicated; linspace, for example, could be coming 
from numpy or from mlab (until we get everything cleaned up...).

So, I think you are stuck with two approaches: actually tracing imports 
back through the code, or running ipython, importing a module, and then 
using the ? facility:

In [1]:import pylab

In [2]:pylab.linspace?
Type:           function
Base Class:     <type 'function'>
String Form:    <function linspace at 0x8541a04>
Namespace:      Interactive
File: 
/usr/local/lib/python2.5/site-packages/numpy/lib/function_base.py
Definition:     pylab.linspace(start, stop, num=50, endpoint=True, 
retstep=False)
Docstring:
     Return evenly spaced numbers.

     Return num evenly spaced samples from start to stop.  If
     endpoint is True, the last sample is stop. If retstep is
     True then return the step value used.

Which shows that at present, the linspace supplied by pylab is actually 
the numeric version, not the mlab version.  This is not at all obvious 
from looking at pylab.py!

Eric

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to