[SciPy-user] assign to diagonal values?
Alan G Isaac
aisaac at american.edu
Sat May 23 17:26:57 EDT 2009
> On Sat, May 23, 2009 at 16:02, Alan G Isaac wrote:
>> On 1/31/2008 1:37 AM Anne Archibald apparently wrote:
>>> m[range(n),range(n)]=new_diagonal
>> Will that work with range objects (in Python 3)?
On 5/23/2009 5:05 PM Robert Kern apparently wrote:
> No. The automatic conversion to arrays does not consume iterators (nor
> will it when we port to Python 3).
Sure, but range objects are not iterators.
They are "almost" sequences.
Python 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC
v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> r = range(10)
>>> next(r)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: range object is not an iterator
>>> 5 in r
True
>>> list(r)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list(r)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Cheers,
Alan Isaac
More information about the SciPy-User
mailing list