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.
> 


Thanks!  Knowing what to look for, google pulled up the following page 
from the python website, delineating the overloadable operators:

http://docs.python.org/ref/numeric-types.html

I put this here for future reference.

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/
-~----------~----~----~----~------~----~------~--~---

Reply via email to