On Jan 23, 12:24 pm, Achim Domma <[EMAIL PROTECTED]> 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
Simple option: how do you feel about using '<<=' instead of '=' (by defining __ilshift__)? This gives you: A <<= B * C (looks sort of like "injecting" the result of B times C into A) More complicated option: embed an expression/assignment parser into your app. You can get a jump on this using some of the examples that come with pyparsing (can check these out online at http://pyparsing.wikispaces.com/Examples - look at fourFn.py and simpleArith.py). -- Paul -- http://mail.python.org/mailman/listinfo/python-list