Windows, IDLE, __doc_, other

W. eWatson wolftracks at invalid.com
Mon Dec 21 14:39:57 EST 2009


Lie Ryan wrote:
> On 12/21/2009 1:19 PM, W. eWatson wrote:
> 
>> When I use numpy.__doc__ in IDLE under Win XP, I get a heap of words 
>> without reasonable line breaks.
>>
>> "\nNumPy\n=====\n\nProvides\n  1. An array object of arbitrary 
>> homogeneous items\n  2. Fast mathematical operations over arrays\n  3. 
>> Linear Algebra, Fourier Transforms, Random Number
>> ....
>>
>> Is there a way to get this formated properly.
> 
> help(object)
> 
> 
>> If I use dir(numpy), I get yet a very long list that starts as:
>> ['ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DataSource', 'ERR_CALL', 
>> 'ERR_DEFAULT', 'ERR_DEFAULT2', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 
>> 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 
>> 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 
>> 'Infinity', 'MAXDIMS', 'MachAr', 'NAN', 'NINF', 'NZERO', 'NaN', 
>> 'PINF', 'PZERO', 'PackageLoader', 'RAISE', 'RankWarning', 
>> 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 
>> 'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'True_', 
>> 'UFUNC_BUFSIZE_DEFAULT'
>> ....
>> I see this might be a dictionary. What can I do to make it more 
>> readable or useful, or is that it? Is there a more abc as in Linux?
> 
> You can use pprint module:
> 
> import pprint
> pprint.pprint(dir(object))
> 
> though help() is usually better
> 
>> It the IDLE shell, it's not possible to retrieve lines entered earlier 
>> without copying them. Is there an edit facility?
> 
> Press Alt+P (Previous) and Alt+N (Next). Or you can click/select on the 
> line you want to copy and press Enter.
> 
>>> Add to this. Isn't there a way to see the arguments and descriptions of
>>> functions?
> 
> Use help(). Or if you're doing this without human intervention, use 
> `inspect` module.
Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and 
a little window came up showing it was about to print hundreds of pages. 
  I can canceled it, but too late. I turned off my printer quickly and 
eventually stopped the onslaught.

I couldn't get Alt-P or N to work.

Another question. In interactive mode, how does one know what modules 
are active? Is there a way to list them with a simple command?



More information about the Python-list mailing list