A newbie question

wang frank fw3 at hotmail.co.jp
Mon May 21 19:58:36 EDT 2007


Thanks all for the help.

It solves my problem. I want to build a class type for fixed point 
operation for a specifc chip. I could not use the build in complex data 
type. It is a daunting job for me since I has not use python before.

Frank


>From: Dan Bishop <danb_83 at yahoo.com>
>To: python-list at python.org
>Subject: Re: A newbie question
>Date: 21 May 2007 16:22:06 -0700
>
>On May 21, 6:04 pm, "wang frank" <f... at hotmail.co.jp> wrote:
> > 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?
>
>return Cc14(self.r+x,r, self.i+x.i)
>
>FYI, Python has a built-in "complex" type.
>
>--
>http://mail.python.org/mailman/listinfo/python-list

_________________________________________________________________
オンライン地図マガジン「地図マガ」創刊!全国水族館マップを特集 
http://chizumaga.jp/ 




More information about the Python-list mailing list