Numeric array of objects
Josiah Carlson
jcarlson at nospam.uci.edu
Wed Mar 3 21:43:50 EST 2004
More information about the Python-list mailing list
Wed Mar 3 21:43:50 EST 2004
- Previous message (by thread): design pattern
- Next message (by thread): Numeric array of objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> You create a 1-D Numeric array of n floats with > > x = zeros(n,Float) > > How do you create a Numeric array of n instances of class 'xy', where > for example xy is defined as follows: > > class xy: > def __init__(self,x=0.0,y=0.0): > self.x = x > self.y = y > > I want the elements of the array to be initialized to the default > value of xy, (0.0,0.0). I have read the Martelli's explanation on p309 > of the book "Python in a Nutshell", but I still don't get it. Numeric.array([xy() for i in xrange(n)], Numeric.PyObject) - Josiah
- Previous message (by thread): design pattern
- Next message (by thread): Numeric array of objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list