Incidentally, this works after http://trac.sagemath.org/16746 where I 
refactored our displayhook (and fixed a handful of bugs). Needs review 
*hint* *hint*

sage: cython("""
....: cdef class A: 
....:     def __iter__(self): 
....:         for i in range(5): yield i 
....: """)
sage: iter(A())
<generator object at 0x7f0da9366d10>



On Saturday, September 20, 2014 10:09:17 AM UTC+1, vdelecroix wrote:
>
> Hi, 
>
> If I do a Cython class 
>
> cdef class A: 
>     def __iter__(self): 
>         for i in range(5): yield i 
>
> then in the console the iterator works fine but not its string 
> representation. 
>
> sage: a = A() 
> sage: iter(a) 
> KeyError                                  Traceback (most recent call 
> last) 
> <ipython-input-6-039e95d088f4> in <module>() 
> ----> 1 iter(w) 
>
> /opt/sage_flatsurf/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc
>  
>
> in __call__(self, result) 
>     251             self.write_output_prompt() 
>     252             format_dict, md_dict = 
> self.compute_format_data(result) 
> --> 253             self.write_format_data(format_dict, md_dict) 
>     254             self.update_user_ns(result) 
>     255             self.log_output(format_dict) 
>
> /opt/sage_flatsurf/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc
>  
>
> in write_format_data(self, format_dict, md_dict) 
>     172         # newline, even if all the prompt separators are ''. This 
> is the 
>     173         # standard IPython behavior. 
> --> 174         result_repr = format_dict['text/plain'] 
>     175         if '\n' in result_repr: 
>     176             # So that multi-line strings line up with the left 
> column of 
>
> KeyError: 'text/plain' 
>
> Does anybody knows where the problem comes from? 
>
> Vincent 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to