Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the option in Julia REPL that allows only a limited output?

The result variable is a json-type string, which is very long. What is the option in Julia REPL that allows only a limited output when the variable is this long? DataFrame is originally only partially output. I hope that the general variables will also be output like that.

enter image description here

like image 876
andyname Avatar asked May 05 '21 12:05

andyname


Video Answer


1 Answers

You can overwrite the display method for AbstractStrings:

import Main.display
display(x::AbstractString) =
           show(length(x)<=50 ? x : SubString(x,1,50)*"…")

Let us test it:

julia> str = join(rand('a':'z', 200))
"wcbifwzglgqyenrcdgdxagohlwdoxrrumoaltklkjauptwzrmi…"
like image 121
Przemyslaw Szufel Avatar answered Sep 19 '22 11:09

Przemyslaw Szufel