[Numpy-discussion] ndarray newbie question
belinda thom
bthom at cs.hmc.edu
Thu Jan 4 15:16:28 EST 2007
Vincent,
Thanks again.
On Jan 4, 2007, at 11:40 AM, Vincent Nijs wrote:
> --b,
>
> The only data type in python that has a keys() method is a dictionary.
Doh!
> Unless it is a record array (http://www.scipy.org/RecordArrays)
> there is no
> information on variable names contained in the object.
There's always dir()...but then you can't tell what is what (e.g. a
whole slew of stuff is reported...vars, methods, ...).
> However, even record
> arrays don't have a keys() method.
>
> Vincent
Some context: the type of introspection I'm often wishing I could do
in a single, easy command usually has to do w/getting to know the
software better. I've been frustrated w/Python at times in this
regard because, for example, printing out all local variables
requires knowing about deeper magic (e.g. locals()).
I realize that open source is less likely to have the bells and
whistles that corporate software can provide (e.g. w/VC++ its trivial
to "watch" all local vars in the debugger), and I'm switching from
matlab to pylab / numpy precisely because its open source. At the
same time, its hard to imagine others don't have access to the kinds
of tricks I'm starting to learn (e.g. dobj). If folks have other
tricks of that type, I'm all ears and quite grateful.
Regarding numpy ndarrays, if I were to write my own viewer, what
internal variables make the most sense to show? Are .ndim, .size,
and .shape the only ones I should care about?
Danke,
--b
More information about the NumPy-Discussion
mailing list