Overloaded Operators allowed???
Jeff
no_spam at umich.edu
Wed Jul 5 19:09:41 EDT 2000
Well yes, that is true, but say I wanted to overload "/" to operate on a
class such as "cookies". Can this be done?
jy
Bjorn Pettersen <bjorn at roguewave.com> wrote in message
news:3963AADB.25A6776E at roguewave.com...
> Jeff wrote:
> >
> > Can you overload operators as you can in other languages? For example,
can
> > I make "&" give the address of something as in C++? Or can I only
overload
> > things like the cmp operator? i.e. I want to say &string and get the
> > address of string.
>
> Since "&string" is illegal syntactically in Python it wouldn't make
> sense to let you overload on it. It would be like saying "I want to
> overload @ in C++ so I can use it to append lists, like list1 @
> list2..."
>
> Besides, you really don't want the address of the string (trust me
> <wink>).
>
> -- bjorn
>
More information about the Python-list
mailing list