1 | initial version |

Yes, in interactive Python sessions, output uses `displayhook`

instead of `repr`

:

```
sage: A=matrix([[1,2],[3,4]])
sage: u=[A,A]
sage: repr(u)
'[[1 2]\n[3 4], [1 2]\n[3 4]]'
sage: import sys
sage: sys.displayhook(u)
[
[1 2] [1 2]
[3 4], [3 4]
]
```

Sage defines it's own module `sage.misc.displayhook`

. Imho that's a dead end, because math formatting is very complex, and the right tool is LaTeX, very well integrated in Sage and Sage Notebook. I suggest you write a method `_latex_(self)`

for your objects, then lists of these objects will be correctly formatted by LaTeX.

2 | precise explication added |

Yes, in interactive Python sessions, output uses `displayhook`

instead of `repr`

:

```
sage: A=matrix([[1,2],[3,4]])
sage: u=[A,A]
sage: repr(u)
'[[1 2]\n[3 4], [1 2]\n[3 4]]'
sage: import sys
sage: sys.displayhook(u)
[
[1 2] [1 2]
[3 4], [3 4]
]
```

Sage defines it's own module `sage.misc.displayhook`

. Imho that's a dead end, because math formatting is very complex, and the right tool is LaTeX, very well integrated in Sage and Sage Notebook. I suggest you write a method `_latex_(self)`

for your objects, then lists of these objects will be correctly formatted by ~~LaTeX.~~LaTeX. Because the *string*

```
'[ repr(A), repr(B) ]'
```

is not a valid representation for [A,B] if there are newlines inside repr(A) and repr(B), while

```
\left[ latex(A), latex(B) \right]
```

is always a valid LaTeX description of [A,B].

3 | No.3 Revision |

Yes, in interactive Python sessions, output uses `displayhook`

instead of `repr`

:

```
sage: A=matrix([[1,2],[3,4]])
sage: u=[A,A]
sage: repr(u)
'[[1 2]\n[3 4], [1 2]\n[3 4]]'
sage: import sys
sage: sys.displayhook(u)
[
[1 2] [1 2]
[3 4], [3 4]
]
```

Sage defines it's own module `sage.misc.displayhook`

. Imho that's a dead end, because math formatting is very complex, and the right tool is LaTeX, very well integrated in Sage and Sage Notebook. I suggest you write a method `_latex_(self)`

for your objects, then lists of these objects will be correctly formatted by LaTeX. ~~Because the ~~The *string*

```
'[ repr(A), repr(B) ]'
```

is not a valid representation for [A,B] if there are newlines inside repr(A) and repr(B), while

```
\left[ latex(A), latex(B) \right]
```

is always a valid LaTeX description of [A,B].

4 | No.4 Revision |

Yes, in interactive Python sessions, output uses `displayhook`

instead of `repr`

:

```
sage: A=matrix([[1,2],[3,4]])
sage: u=[A,A]
sage: repr(u)
'[[1 2]\n[3 4], [1 2]\n[3 4]]'
sage: import sys
sage: sys.displayhook(u)
[
[1 2] [1 2]
[3 4], [3 4]
]
```

Sage defines it's own module `sage.misc.displayhook`

. Imho that's a dead end, because math formatting is very complex, and the right tool is LaTeX, very well integrated in Sage and Sage Notebook. I suggest you write a method `_latex_(self)`

for your objects, then lists of these objects will be correctly formatted by LaTeX. The *string*

~~'[ repr(A), ~~'[' + repr(A) + ',' + repr(B) ~~]'
~~+ ']'

is not a valid representation for [A,B] if there are newlines inside repr(A) and repr(B), while

~~\left[ latex(A), ~~'\left[' + latex(A) + ',' + latex(B) ~~\right]
~~+ '\right]'

is always a valid LaTeX description of [A,B].

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.