apardon at forel.vub.ac.be
Wed Jan 12 03:07:52 EST 2005
Op 2005-01-12, It's me schreef <itsme at yahoo.com>:
> "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?
I suppose in the same way as (graphic) points and vectors can be
A few years back I had written a Vector class in python, just
to get an understanding of how things worked. It worked without
a problem with your twice function.
>>> def twice(a):
... return 2 * a
I suppose what can be done with a vector class could have been
done with a complex class should complex numbers not have been
native to python.
More information about the Python-list