Hello everybody !!!

I am working with operators these days, and I wondered if there was a
reason behind the fact that defining the + operator does not mean the
"sum" function will work.

For graphs, the + operator means the disjoints union. Why shouldn't
the following code be accepted by Sage ?

sage: g = graphs.PetersenGraph()
sage: h = graphs.PetersenGraph()
sage: sum([g,h])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/marsu/.sagebin/devel/sage-main/sage/graphs/<ipython console> in <module>()

/home/marsu/.sagebin/local/lib/python2.6/site-packages/sage/misc/functional.pyc
in symbolic_sum(expression, *args, **kwds)
    657         return expression.sum(*args, **kwds)
    658     elif len(args) <= 1:
--> 659         return sum(expression, *args)
    660     else:
    661         from sage.symbolic.ring import SR

TypeError: unsupported operand type(s) for +: 'int' and 'Graph'


Besides, the exception given is odd : addition between int and Graph
types... :-)

Thank youuuuuu !

Nathann

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to