TypeError: 'sage.rings.integer.Integer' object is not iterableg

420 views
Skip to first unread message

baby bunny

unread,
May 29, 2014, 3:49:10 PM5/29/14
to sage-s...@googlegroups.com


Hi, I'm new to sage. I'm reading the tutorial and trying out examples. But when I try this example:
sage: class Evens(list):
...       def __init__(self, n):
...           self.n = n
...           list.__init__(self, range(2, n+1, 2))
...       def __repr__(self):
...           return "Even positive numbers up to n."
 
sage: e = Evens(10)
sage: e
Even positive numbers up to n.

from http://www.sagemath.org/doc/tutorial/tour_help.html,
after entering the class definition, when I type in
e = Evens(10)
I get the error: TypeError: 'sage.rings.integer.Integer' object is not iterable
Why is that? Thanks!

Simon King

unread,
May 29, 2014, 4:13:49 PM5/29/14
to sage-s...@googlegroups.com
Hi,
The example works for me. Did you perhaps make a misprint when you tried
it? For example, if you misspelled "__init__" (double underscore in the
beginning and in the end), then Evens(10) would exactly result in the
error you describe.

Best regards,
Simon


Reply all
Reply to author
Forward
0 new messages