Numeric array of objects

beliavsky at aol.com beliavsky at aol.com
Thu Mar 4 00:08:38 CET 2004


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.



More information about the Python-list mailing list