# [Matrix-SIG] Syntactic sugar for constructing arrays

Charles G Waldman cgw@pgt.com
29 Sep 1998 13:12:06 -0400

```The following message is a courtesy copy of an article
that has been posted to comp.lang.python as well.

The more I use Numeric Python, the more I appreciate the expressive
power it adds to Python.  I do a fair amount of geometric work, and I
find it very elegant to be able to write things like:

point = point+offset
or

def distance(p1,p2):
return sqrt(sum((p1-p2)**2))

where point, offset, p1, p2 are 1-dimensional NumPy arrays.  This
takes Python, IMO, to a level of sophistication well beyond a "nifty
easy-to-use scripting language"; it becomes a very attractive
environment for doing math/scientific work.

I used to write X-Y coordinates as 2-tuples, but things like vector
addition are much less elegant this way than they are if I use NumPy
arrays.  The more I use Numeric Python, the more I realize that for
lots of mathematical structures like points, a 1-D NumPy array is a
much better representation than a tuple.

The downside of this is that my code is now littered with the construction:

center = array((256,256))
point = array((10,-20))

etc.

Since the array is such a useful type, I'd like to see a
cleaner-looking syntax for creating array objects.  I'd like to be
able to write, for instance,

center = <256,256>
point =  <10,-20>

What do people think of this suggestion?

```