# Way to store what is normally printed in the REPL to a string or file?

**URL:** <https://discourse.julialang.org/t/way-to-store-what-is-normally-printed-in-the-repl-to-a-string-or-file/53068>\
**Category:** General Usage\
**Created:** [January 8, 2021, 10:02pm UTC](https://discourse.julialang.org/t/way-to-store-what-is-normally-printed-in-the-repl-to-a-string-or-file/53068 "2021-01-08T22:02:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [January 8, 2021, 10:02pm UTC](https://discourse.julialang.org/t/way-to-store-what-is-normally-printed-in-the-repl-to-a-string-or-file/53068/1 "2021-01-08T22:02:12Z")

</div>

I specifically want to store the outputs of `@code_warntype` to a string or file so I can read through it later, but I’m also interested in doing something similar for any expression that prints to the REPL.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [January 8, 2021, 11:03pm UTC](https://discourse.julialang.org/t/way-to-store-what-is-normally-printed-in-the-repl-to-a-string-or-file/53068/2 "2021-01-08T23:03:40Z")

</div>

`code_warntype` lets you pass an IO object as the first argument so you can do something like this:

```julia
julia> f(x, y) = x * y;

julia> open("file.txt", "w") do io
           code_warntype(io, f, Tuple{Int, Int})
       end

```

```bash
$ cat file.txt
Variables
  #self#::Core.Compiler.Const(f, false)
  x::Int64
  y::Int64

Body::Int64
1 ─ %1 = (x * y)::Int64
└── return %1

```

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [January 9, 2021, 8:24am UTC](https://discourse.julialang.org/t/way-to-store-what-is-normally-printed-in-the-repl-to-a-string-or-file/53068/3 "2021-01-09T08:24:35Z")

</div>

I totally forgot about the function `code_warntype`. Considering that `print` and other similar functions all have that `IO` option, I’m figuring that there’s the only way to specify where the printed content goes; can’t change it after the fact.
