Overloading assignment operator

Russ uymqlp502 at sneakemail.com
Tue Jan 23 21:07:55 EST 2007


Achim Domma wrote:
> Hi,
>
> I want to use Python to script some formulas in my application. The user
> should be able to write something like
>
> A = B * C
>
> where A,B,C are instances of some wrapper classes. Overloading * is no
> problem but I cannot overload the assignment of A. I understand that
> this is due to the nature of Python, but is there a trick to work around
> this?
> All I'm interested in is a clean syntax to script my app. Any ideas are
> very welcome.
>
> regards,
> Achim

Why do you need to overload assignment anyway? If you overloaded "*"
properly, it should return
the result you want, which you then "assign" to A as usual. Maybe I'm
missing something.




More information about the Python-list mailing list