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 >From: "wang frank" <[EMAIL PROTECTED]> >To: python-list@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 > >_________________________________________________________________ >ウェブページを印刷しても途切れない!便利なブラウザ MSN版IE7 を使おう >http://promotion.msn.co.jp/ie7/ > >-- >http://mail.python.org/mailman/listinfo/python-list _________________________________________________________________ オンライン地図マガジン「地図マガ」創刊!全国水族館マップを特集 http://chizumaga.jp/ -- http://mail.python.org/mailman/listinfo/python-list