[Numpy-discussion] Dcoument strings for ndarray
Colin J. Williams
cjw at sympatico.ca
Mon Oct 10 04:53:30 EDT 2005
Travis Oliphant wrote:
>>> I'm not sure what you are talking about here? Where are you getting
>>> I don't know of any such attribute. There is a __class__
>>> attribute. But I don't see a
>>> __class__ module(name[, doc]) attribute
>> Please see the sequence below:
>> >>> import scipy.base.multiarray as M
>> >>> M.__class__
>> <type 'module'>
>> I am surprised that this name points to a module. It usually is an
>> attribute of a class instance which
>> points to the class object of that instance.
> Why is this surprising? scipy.base.multiarray is a module, therefore
> it's "class" is type 'module'. This seems fine to me. At any rate,
> Python is assigning the __class__ attribute to the extension module
> multiarray, so it is what it is.
Yes, this is the Python practice:
>>> import timeit
>>> import anydbm
Yes, timeit.__class__ points to the internal module creator function:
>>> import new
'module(name[, doc])\n\nCreate a module object.\nThe name must be a
string; the optional doc argumen
t can have any type.'
>>> new.module is timeit.__class__
With a little digging, this is logical, consistent and no longer surprising.
More information about the NumPy-Discussion