# Show() and sisters

**URL:** <https://discourse.julialang.org/t/show-and-sisters/8927>\
**Category:** General Usage\
**Created:** [February 8, 2018, 3:10pm UTC](https://discourse.julialang.org/t/show-and-sisters/8927 "2018-02-08T15:10:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![j2b2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j2b2/32/3387_2.png) [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Post date:** [February 8, 2018, 3:10pm UTC](https://discourse.julialang.org/t/show-and-sisters/8927/1 "2018-02-08T15:10:05Z")

</div>

Hi, here is my code :

```julia
julia> using Primes

julia> f=factor(binomial(30,12))
3 ⋅ 5^2 ⋅ 7 ⋅ 13 ⋅ 19 ⋅ 23 ⋅ 29

julia> repr(f)
"Primes.Factorization(3=>1,5=>2,7=>1,13=>1,19=>1,23=>1,29=>1)"

julia> string(f)
"Primes.Factorization(3=>1,5=>2,7=>1,13=>1,19=>1,23=>1,29=>1)"

```

`Primes.Factorization` has a nice `show()` method, but how to build a string from this representation ?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 8, 2018, 3:14pm UTC](https://discourse.julialang.org/t/show-and-sisters/8927/3 "2018-02-08T15:14:22Z")

</div>

```julia
julia> reprmime("text/plain", f)
"3 ⋅ 5^2 ⋅ 7 ⋅ 13 ⋅ 19 ⋅ 23 ⋅ 29"

```

---

<div class="post-metadata">

**Author:** ![j2b2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j2b2/32/3387_2.png) [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Post date:** [February 8, 2018, 3:21pm UTC](https://discourse.julialang.org/t/show-and-sisters/8927/4 "2018-02-08T15:21:57Z")

</div>

Wow, thank you a lot, this function is well hidden in the doc !

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 9, 2018, 1:51pm UTC](https://discourse.julialang.org/t/show-and-sisters/8927/5 "2018-02-09T13:51:37Z")

</div>

I did not find it from the docs, if you `?repr` it shows up in the search.

---

<div class="post-metadata">

**Author:** ![j2b2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j2b2/32/3387_2.png) [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Post date:** [February 10, 2018, 3:50pm UTC](https://discourse.julialang.org/t/show-and-sisters/8927/6 "2018-02-10T15:50:26Z")

</div>

You’re right, but I used the doc, where `repr` and `string` are in  
[https://docs.julialang.org/en/stable/stdlib/strings/](https://docs.julialang.org/en/stable/stdlib/strings/) (that looks fine :-),  
whereas `reprmime` and `stringmime` are in  
[https://docs.julialang.org/en/stable/stdlib/io-network/](https://docs.julialang.org/en/stable/stdlib/io-network/) .

Anyway imho `repr` should be the good answer.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 10, 2018, 5:04pm UTC](https://discourse.julialang.org/t/show-and-sisters/8927/7 "2018-02-10T17:04:51Z")

</div>

> [@j2b2](#):
>
> Anyway imho repr should be the good answer.

`repr` is equivalent to `show(io, x)`, whereas `reprmime` (documented [here](https://docs.julialang.org/en/stable/stdlib/io-network/#Base.Multimedia.reprmime)) is equivalent to `show(io, mime, x)`. The latter defaults to the former for `text/plain`, but it is sometimes desirable to distinguish the two, as described here: [https://docs.julialang.org/en/stable/manual/types/#Custom-pretty-printing-1](https://docs.julialang.org/en/stable/manual/types/#Custom-pretty-printing-1)

Usually, you want `repr(x)` to be a form that you could use to enter the same object, i.e. `includestring(repr(x))` should usually work. Whereas the `text/plain` version might be a more pretty-printed output that is designed for human consumption, not computer parsing.

That being said, I suspect that we should rename `reprmime(mime, x)` to `repr(mime, x)`, just as `writemime(io, mime, x)` was renamed to `show(io, mime, x)`.
