Pierre GM wrote:
> I agree that this one is not really informative. A
a.__class__.__doc__?
> provides a docstring interestingly truncated under ipython, but nothing
> useful either.
"a.__class__?" is the command that you are after, not "a.__class__.__doc__?".
a.__class__.__doc__ is a strin
On 1/5/07, Pierre GM <[EMAIL PROTECTED]> wrote:
> belinda thom wrote:
> > > 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.
>
> For generic introspection in Python, dir and .__doc__ a
belinda thom wrote:
> > 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.
For generic introspection in Python, dir and .__doc__ are very useful.
The ? trick works in ipython and prints
belinda thom wrote:
> Pierre,
>
> Thanks for the reply.
>
> > 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.
>
> dir?
> obj.__doc__ ?
>
> When I try the latter recommendation abov
Pierre,
Thanks for the reply.
> 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.
dir?
obj.__doc__ ?
When I try the latter recommendation above w/numpy arrays, I get:
In [1]: import num
> > However, even record
> > arrays don't have a keys() method.
You can access the attributes of a recarray by
N.ndarray.__getattribute__(obj,'dtype').fields
which is yet another dictproxy.
> Some context: the type of introspection I'm often wishing I could do
> in a single, easy command usually
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 obje
On Thursday 04 January 2007 14:18, belinda thom wrote:
> Hello,
>
> I wrote a "display obj" method for viewing instance data:
...
> and I'm wondering why it doesn't work on ndarrays:
An (instance of) ndarray doesn't have a __dict__ attribute, as you've
noticed.
The class ndarray does have one.
belinda thom wrote:
> Hello,
>
> I wrote a "display obj" method for viewing instance data:
>
> def dobj(obj) :
> """extended object viewer that displays arg"""
> print 'Class: ', obj.__class__.__name__, ' id:', id(obj)
> for k in obj.__dict__.keys() :
> print ' ', k, ': '
--b,
The only data type in python that has a keys() method is a dictionary.
Unless it is a record array (http://www.scipy.org/RecordArrays) there is no
information on variable names contained in the object. However, even record
arrays don't have a keys() method.
Vincent
On 1/4/07 1:18 PM, "b
Hello,
I wrote a "display obj" method for viewing instance data:
def dobj(obj) :
"""extended object viewer that displays arg"""
print 'Class: ', obj.__class__.__name__, ' id:', id(obj)
for k in obj.__dict__.keys() :
print ' ', k, ': ', obj.__dict__[k], ' id:', id(obj.__di
11 matches
Mail list logo