[Numpy-discussion] NumPy-Discussion Digest, Vol 85, Issue 19

Nathaniel Smith njs at pobox.com
Mon Oct 7 16:54:35 EDT 2013


On Mon, Oct 7, 2013 at 9:40 PM, Siegfried Gonzi
<sgonzi at staffmail.ed.ac.uk> wrote:
> [I hope I am not screwing up the digest reply function here].

[You did, FYI. It happens...]

> I am after a  "whos" which would work in a script. It is not very often that
> I develop code at the command line.
>
> I am definitely not one of the best  programmers out there but I used "help"
> a lot in my IDL  scripts and code. Our research group is migrating away from
> IDL towards Python.
>
> I think Python's help is not the same than IDL's help. I know copying things
> from other languages is not always a good idea but one cannot argue that
> IDL's help comes in rather handy while developing and testing code.

>From a script try:

print(repr(obj))

or

print(type(obj))

or if you always want just a 1 line summary:

def idl_help(obj):
    if isinstance(obj, np.ndarray):
        print("<ndarray with shape %s, dtype=%s>" % (obj.shape, obj.dtype))
    else:
        print(type(obj)
idl_help(obj)

(Customize to suit)

-n



More information about the NumPy-Discussion mailing list