W
wang frank
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 __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
_________________________________________________________________
$B%*%s%i%$%sCO?^%^%,%8%s!VCO?^%^%,!WAO4)!*A49q?eB24[%^%C%W$rFC=8(B
http://chizumaga.jp/
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" <[email protected]>
To: (e-mail address removed)
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/
_________________________________________________________________
$B%*%s%i%$%sCO?^%^%,%8%s!VCO?^%^%,!WAO4)!*A49q?eB24[%^%C%W$rFC=8(B
http://chizumaga.jp/