REPOST: Re: 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
---------
========= WAS CANCELLED BY =======:
Path: news.sol.net!spool0-nwblwi.newsops.execpc.com!newsfeeds.sol.net!newspump.sol.net!newsfeed.direct.ca!look.ca!newsfeed.dacom.co.kr!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r
From: "Emile van Sebille" <emile at fenx.com>
Newsgroups: comp.lang.python
Subject: cmsg cancel <a0kmd5$li55v$1 at ID-11957.news.dfncis.de>
Control: cancel <a0kmd5$li55v$1 at ID-11957.news.dfncis.de>
Date: Mon, 31 Dec 2001 05:11:42 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.a0kmd5$li55v$1 at ID-11957.news.dfncis.de>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news2.kornet.net 1009774744 27193 211.57.49.2 (31 Dec 2001 04:59:04 GMT)
X-Complaints-To: usenet at news2.kornet.net
NNTP-Posting-Date: Mon, 31 Dec 2001 04:59:04 +0000 (UTC)
X-No-Archive: yes
X-Unac4ncel: yes
X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999)
This message was cancelled from within Mozilla.
More information about the Python-list
mailing list