On Dec 29, 2008, at 4:15 PM, William Stein wrote:

> On Mon, Dec 29, 2008 at 2:43 PM, Justin Walker <jus...@mac.com> wrote:
>>
>> On Dec 29, 2008, at 5:23 PM, John Cremona wrote:
>>
>>>
>>> Maybe I missed the point here but after
>>
>> The point was a minor one...
>>
>>> R.<x1,x2>=QQ[]
>>> M=matrix(R,1,2,[x1+x2,x1*x2])
>>>
>>> you can get at the entries like this:
>>> sage: M[0,0]
>>> x1 + x2
>>> sage: M[0,1]
>>> x1*x2
>>
>> For the OP, it was surprising that "list(M)" did not return a list of
>> the entries of M.  The reason is that (for Python, I think), M is a
>> list of "rows".  The expression "M.list()" does return a list of the
>> entries of M, which is what one might naively expect of the former
>> expression.
>>
>> In the world of objects, its not always clear what the object is, I
>> guess.
>>
>
> If X is a python object, then list(X) literally makes the list list
> X[0], X[1], etc., until the Python interpreter gets and IndexError.
> It doesn't call "X.list()".
>
> I think that list(X) and X.list() are different for matrices is an
> unfortunate inconsistency.     The best fix I can think of would be to
> eliminate the list method entirely, and have a method
> X.list_of_entries() or X.entries().  Just changing .list()'s
> definition would be dangerous, since a lot of code probably depends on
> the current definition.  Changing list(X) to behave differently would
> likely require making X[0] return the first entry of X rather than the
> first row, which would be really confusing.

+1 to (deprecating then removing) removing X.list(), and replacing it  
with X.entries().

> That X[0] returns the first row instead of the first column is a
> completely arbitrary choice.  It had to be made, so it was made.


I don't think it's quite arbitrary, M[a][b] == M[a,b] seems a lot  
more natural than the other way, and the latter ordering, though  
perhaps arbitrary, seems to be the more conventional one.

- Robert



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to