On Apr 22, 8:47 am, "Anton Mellit" <[EMAIL PROTECTED]> wrote: > I need something like > 'overriding' =, which is impossible, but I look for a systematic > approach to do something instead. It seems there are two ways to do > what I need: > > 1. Implement a method 'assign' which generates the corresponding code > to store value: > > z.assign(x + y) > > 2. Do the same as 1., but via property set methods. For example, this > would look cleaner: > > z.value = x + y > > Which of these is preferrable? Does anyone know any alternative ways? > > Anton
If you are willing to accept '<<=' as meaning 'assign to existing' instead of 'left shift in place', you can override this operator using the __ilshift__ method. We used this technique in C++/CORBA code back in the 90's to "inject" values into CORBA::Any variables. -- Paul -- http://mail.python.org/mailman/listinfo/python-list