No, I don't think you can make custom infix operators in Python. With something as long as 'boxproduct', you'd probably just be better off making it a method.
--Mike On 9/26/07, Jason Grout <[EMAIL PROTECTED]> wrote: > > Mike Hansen wrote: > > Since I don't think that graphs and polytopes fall under the SAGE > > coercion model, overloading operators is pretty straightforward. You > > just need to define the __add__ method in your class. x + y will call > > x.__add__(y). > > > > sage: class Foo: > > ....: def __add__(self, y): > > ....: return 42 > > ....: > > sage: a = Foo() > > sage: b = Foo() > > sage: a + b > > 42 > > sage: b + a > > 42 > > > > Note that you'll want to do some type-checking so that y is what you > > actually think it should be. > > Can we define custom infix operators? Suppose I'd like "boxproduct" to > be an infix operator. Could I make that work? > > Thanks, > > Jason > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---