[PYTHON MATRIX-SIG] lists vs. tuples
James Hugunin
jjh@Goldilocks.LCS.MIT.EDU
Fri, 2 Feb 96 10:31:26 EST
From: da@maigret.cog.brown.edu (David Ascher)
Just a thought.
I believe that most existing python code, when returning collections,
return tuples.
The matrix code as implemented returns lists (e.g. shape). Shape
strikes me as the kind of thing which might be better off being a tuple
than a list. That way people doing:
a = array(...)
s = a.shape()
s[0] = 3
would be stopped by the interpreter (I'm assuming this isn't working and
isn't likely to work).
Your code fragment won't work for two reasons. First, a.shape is a
data member, not a function (this is because you can do a.shape =
new_shape). And the data member a.shape is a tuple. You are allowed
to assign to a.shape from any sequence type, but it can only be
accessed as a tuple.
Are you thinking of some other problem?
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================