I am trying to write a python class with a new data type such as:
class Cc14:
def __init__(self, realpart, imagpart):
self.r=realart
self.i=imagpart
def __saturator(x):
return x+1
def out(self,x):
return Cc14(__saturator(x.r), __saturator(x,i))
When I use the method out such as:
z.out
Python complains:
global name '_Cc14_saturator' is not defined.
Is the way put two underscore in front of the definitio making the method
becomes private?
Why in the same clase, I could not use the __saturator method?
Thanks
Frank
>From: "wang frank" <fw*@hotmail.co.jp>__________________________________________________ _______________
To: py*********@python.org
Subject: A newbie question
Date: Mon, 21 May 2007 23:04:06 +0000
Hi,
I am trying to write a python class with a new data type such as:
class Cc14:
def __init__(self, realpart, imagpart):
self.r=realart
self.i=imagpart
def __add__(self,x):
return self.r+x,r, self.i+x.i
If I have
x=Cc14(4,5)
y=Cc14(4,5)
z=x+y
z will be a tuple instead of Cc14. How can I return a Cc14 class?
Thanks
Frank
_________________________________________________ ________________
$B%&%'%V%Z!<%8$r0u:~$7$F$bES@Z$l$J$$!*JXMx$J%V%i %&%6(B MSN$BHG(BIE7 $B$r;H$*$&(B
http://promotion.msn.co.jp/ie7/
--
http://mail.python.org/mailman/listinfo/python-list
$B%*%s%i%$%sCO?^%^%,%8%s!VCO?^%^%,!WAO4)!*A49q?eB 24[%^%C%W$rFC=8(B
http://chizumaga.jp/