Numeric array of objects

John Hunter jdhunter at ace.bsd.uchicago.edu
Thu Mar 4 03:50:00 CET 2004


 > How do you create a Numeric array of n instances of class 'xy', where
 > for example xy is defined as follows:

from Numeric import PyObject, array

class xy:
    def __init__(self,x=0.0,y=0.0):
        self.x = x
        self.y = y

a = array([xy() for i in range(10)], typecode=PyObject)

JDH




More information about the Python-list mailing list