In an ask.sagemath.org question [1], DSM found that since len(sqrt(2))
works, it causes matplotlib to assume that sqrt(2) is an iterable [2].
What is the use-case for having a length function for a symbolic
expression, especially when you can't list that expression?
sage: a=sqrt(2)
sage: len(a)
2
sage: list(a)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Users/grout/sage-trees/sage-4.7.alpha2/spkg/standard/matplotlib-1.0.1.p0/<ipython
console> in <module>()
TypeError: 'sage.symbolic.expression.Expression' object is not iterable
The docs for a.__len__ say:
Returns the number of arguments of this expression.
and all it does is return self.number_of_operands().
To me, if len(a) works, then a should probably be iterable. Does anyone
object if we depreciate the __len__ function on symbolic expressions,
and instead point people to number_of_operands or len(a.operands())?
Thanks,
Jason
[1] http://ask.sagemath.org/question/454/can-gridlines-be-painted-at-sqrt2
[2] I'm also sending a message to matplotlib (or Michael D. at Sage Days
29 :) to ask if they can check for iterability by either explicitly
calling iter() or checking for to see if the object is an instance of
collections.Iterable...
--
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