complex numbers

It's me itsme at yahoo.com
Tue Jan 11 23:22:00 EST 2005


"Robert Kern" <rkern at ucsd.edu> wrote in message
news:cs1mp9$sg9$1 at news1.ucsd.edu...
>
> That's *it*.

So, how would you overload an operator to do:

With native complex support:

def  twice(a):
    return 2*a

print twice(3+4j), twice(2), twice("abc")

Let's presume for a moment that complex is *not* a native data type in
Python.  How would we implement the above - cleanly?





More information about the Python-list mailing list