Numeric array of objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • beliavsky@aol.com

    Numeric array of objects

    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.
Working...