need help with class of arrays which have attibutes

Emile van Sebille emile at fenx.com
Sat Dec 29 10:04:35 EST 2001


"Rob" <rob at pythonemproject.com> wrote in message
news:3C2D3C2C.C9EF5AFE at pythonemproject.com...
>
> Hi Emile,  I've been reading the books and experimenting with different
> kinds of classes, but it just doesn't seem possible to use an array as a
> basis for a number of class attributes.  For example,
> wire=conductor (i.e. class)  wire[1].x1=30  wire[2].x2=40  etc.    Rob.

import Numeric

class Test:
    def __init__(self):
        self.attrs = Numeric.zeros(10)

    def __repr__(self):
        return repr(self.attrs)


t1 = Test()
t1.attrs[2] = 1

t2 = Test()
t2.attrs[2] = 2

print t1
print t2



HTH,

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list