# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=1055

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 1056

---

## [How does one enforce type safety and readability using Julia](https://discourse.julialang.org/t/how-does-one-enforce-type-safety-and-readability-using-julia/3066)

<div class="topic-metadata">

**Author:** [@Jackels](https://discourse.julialang.org/u/Jackels)\
**Replies:** 2\
**Last updated:** [April 5, 2017, 4:20pm UTC](https://discourse.julialang.org/t/how-does-one-enforce-type-safety-and-readability-using-julia/3066 "2017-04-05T16:20:22Z")

</div>

I am currently designing a method that must be able to accept many different, but similar, encoders. The framework for this encoder is simple. It accepts a Vector of bytes and spits out a Vector of bytes. How can I nota…

---

## [How to pass julia flags while calling Julia from Python](https://discourse.julialang.org/t/how-to-pass-julia-flags-while-calling-julia-from-python/3064)

<div class="topic-metadata">

**Author:** [@Karan\_Aggarwal](https://discourse.julialang.org/u/Karan_Aggarwal)\
**Replies:** 0\
**Last updated:** [April 5, 2017, 2:04pm UTC](https://discourse.julialang.org/t/how-to-pass-julia-flags-while-calling-julia-from-python/3064 "2017-04-05T14:04:27Z")

</div>

I am trying to call julia from python code. Everything is working fine but know I need to pass julia arguments such as -O3 ,-compile=yes and–output-o flags. How can I pass these flags from python so that it works in jul…

---

## [Optional arguments to inner type constructor](https://discourse.julialang.org/t/optional-arguments-to-inner-type-constructor/3044)

<div class="topic-metadata">

**Author:** [@kkmann](https://discourse.julialang.org/u/kkmann)\
**Replies:** 6\
**Last updated:** [April 5, 2017, 11:51am UTC](https://discourse.julialang.org/t/optional-arguments-to-inner-type-constructor/3044 "2017-04-05T11:51:30Z")

</div>

Hi, I am trying to implement a type with optional arguments to its inner constructor, like type A b c function A(b; c = 1) new(b, c) end end which works like a charm when I call A(2). However, …

---

## [Loading an unregistered package](https://discourse.julialang.org/t/loading-an-unregistered-package/3051)

<div class="topic-metadata">

**Author:** [@turquoise](https://discourse.julialang.org/u/turquoise)\
**Replies:** 3\
**Last updated:** [April 5, 2017, 11:43am UTC](https://discourse.julialang.org/t/loading-an-unregistered-package/3051 "2017-04-05T11:43:23Z")

</div>

Hi, I added the package JuliBoots using Pkg.clone(“https://github.com/mfpaulos/JuliBoots.git”) However, when I enter using JuliBoots it returns ArgumentError: Module JuliBoots not found in current path. Run Pkg.add…

---

## [Why can julia packages not be called Exam-ple.jl](https://discourse.julialang.org/t/why-can-julia-packages-not-be-called-exam-ple-jl/3055)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 2\
**Last updated:** [April 5, 2017, 11:23am UTC](https://discourse.julialang.org/t/why-can-julia-packages-not-be-called-exam-ple-jl/3055 "2017-04-05T11:23:20Z")

</div>

I just noticed that this fails: Pkg.clone("https://github.com/floswald/Exam-ple.jl") I found no reference to a naming restriction of julia packages. It is a bit odd that this restriction be in place, given that the “da…

---

## [Bug of replace?](https://discourse.julialang.org/t/bug-of-replace/3023)

<div class="topic-metadata">

**Author:** [@AStupidBear](https://discourse.julialang.org/u/AStupidBear)\
**Replies:** 2\
**Last updated:** [April 5, 2017, 6:19am UTC](https://discourse.julialang.org/t/bug-of-replace/3023 "2017-04-05T06:19:06Z")

</div>

replace("123\\n", r"(\\n)", s"\\1") is OK, but replace("123\\n", r"(\\n)", s"\\r\\1") reports “Bad replacement string”. Is this a bug of function replace?

---

## [Require some external program](https://discourse.julialang.org/t/require-some-external-program/3048)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 5\
**Last updated:** [April 4, 2017, 6:24pm UTC](https://discourse.julialang.org/t/require-some-external-program/3048 "2017-04-04T18:24:19Z")

</div>

How do you specify a dependency on some external program in your package? I need to read meta data from a variation of video files and I thought I’d use ExifTool (please let me know if there is a julian alternative). Is…

---

## [Macro magic: looping over varargs printing values and symbols](https://discourse.julialang.org/t/macro-magic-looping-over-varargs-printing-values-and-symbols/3025)

<div class="topic-metadata">

**Author:** [@kkmann](https://discourse.julialang.org/u/kkmann)\
**Replies:** 4\
**Last updated:** [April 4, 2017, 11:16am UTC](https://discourse.julialang.org/t/macro-magic-looping-over-varargs-printing-values-and-symbols/3025 "2017-04-04T11:16:06Z")

</div>

Hey, I am embarrassed to admit that today I surrendered to Julia’s meta programming x) What I want to do is write a macro @check a b c … which checks the varargs input in turn and prints an informative error message wi…

---

## [Sort by more than one element?](https://discourse.julialang.org/t/sort-by-more-than-one-element/3026)

<div class="topic-metadata">

**Author:** [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Replies:** 5\
**Last updated:** [April 4, 2017, 7:47am UTC](https://discourse.julialang.org/t/sort-by-more-than-one-element/3026 "2017-04-04T07:47:18Z")

</div>

Is it possible to sort an array by more than one column? julia\> x 4-element Array{Array{Int64,1},1}: \[1,1,1,5,1\] \[2,1,3,2,1\] \[3,1,1,1,5\] \[1,3,2,4,1\] julia\> sort(x, by = x -\> x\[1\]) # sort by first element, yes 4-ele…

---

## [How to handle "optional data"?](https://discourse.julialang.org/t/how-to-handle-optional-data/2604)

<div class="topic-metadata">

**Author:** [@helgee](https://discourse.julialang.org/u/helgee)\
**Replies:** 4\
**Last updated:** [April 4, 2017, 6:17am UTC](https://discourse.julialang.org/t/how-to-handle-optional-data/2604 "2017-04-04T06:17:20Z")

</div>

Hi everyone, Let’s say I have a package that provides some functions. Of these functions only a few depend on some global data downloaded from the internet. The package should be able to download the data automatically …

---

## [Juno works great now](https://discourse.julialang.org/t/juno-works-great-now/3004)

<div class="topic-metadata">

**Author:** [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Replies:** 5\
**Last updated:** [April 4, 2017, 3:30am UTC](https://discourse.julialang.org/t/juno-works-great-now/3004 "2017-04-04T03:30:28Z")

</div>

I’ve been trying Juno on and off over the last year, and every time I gave up because I’d run into some error when trying to use the Julia features. I write code in Atom but just use the REPL to run it. Today I tried Ju…

---

## [Scrolling in Julia help](https://discourse.julialang.org/t/scrolling-in-julia-help/2988)

<div class="topic-metadata">

**Author:** [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Replies:** 2\
**Last updated:** [April 3, 2017, 6:05pm UTC](https://discourse.julialang.org/t/scrolling-in-julia-help/2988 "2017-04-03T18:05:14Z")

</div>

When I access help from the Julia REPL, the entire documentation for a function prints out. For an extensively documented function (such as DataFrame), I have to scroll through the docs using the terminal/tmux/etc. In R,…

---

## [Dynamic reporting in Julia](https://discourse.julialang.org/t/dynamic-reporting-in-julia/3024)

<div class="topic-metadata">

**Author:** [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Replies:** 3\
**Last updated:** [April 3, 2017, 5:31pm UTC](https://discourse.julialang.org/t/dynamic-reporting-in-julia/3024 "2017-04-03T17:31:30Z")

</div>

Is there a package for Dynamic Reporting in Julia like knitr in R language? I know we can run Julia in Jupyter Notebooks and produce report. But, I would like to keep my codes in a separate file and run reports in anothe…

---

## [Threading in Julia](https://discourse.julialang.org/t/threading-in-julia/2941)

<div class="topic-metadata">

**Author:** [@daytona](https://discourse.julialang.org/u/daytona)\
**Replies:** 4\
**Last updated:** [April 3, 2017, 1:00pm UTC](https://discourse.julialang.org/t/threading-in-julia/2941 "2017-04-03T13:00:29Z")

</div>

I have an application where I want to launch two Julia functions as separate threads. Those threads have a shared matrix they each read from and add extra columns to. Any ideas as to how to go about this? One major conc…

---

## [Terminate in collect](https://discourse.julialang.org/t/terminate-in-collect/3022)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [April 3, 2017, 12:46pm UTC](https://discourse.julialang.org/t/terminate-in-collect/3022 "2017-04-03T12:46:54Z")

</div>

I have a generator which yields state, weight pairs. The type of state is not known in advance. I would like to collect enough states so that the sum of weights is at least S. I prefer to utilize the nice “narrowest type…

---

## [Developing and deploying to cloud with pycall](https://discourse.julialang.org/t/developing-and-deploying-to-cloud-with-pycall/3009)

<div class="topic-metadata">

**Author:** [@datnamer](https://discourse.julialang.org/u/datnamer)\
**Replies:** 0\
**Last updated:** [April 2, 2017, 2:30pm UTC](https://discourse.julialang.org/t/developing-and-deploying-to-cloud-with-pycall/3009 "2017-04-02T14:30:40Z")

</div>

Hi Everyone, Can a Julia + PyCall package be reliably deployed to and run from a web service? Are there any tutorials or instructions for how to do so? I’d like to run a Julia webapp on azure using Python’s azure APIs. …

---

## [Relationship between names, variables and values](https://discourse.julialang.org/t/relationship-between-names-variables-and-values/3007)

<div class="topic-metadata">

**Author:** [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Replies:** 6\
**Last updated:** [April 2, 2017, 12:26pm UTC](https://discourse.julialang.org/t/relationship-between-names-variables-and-values/3007 "2017-04-02T12:26:01Z")

</div>

Are variables bound to their name in Julia? i.e. If I assign a different value to the same name in Julia will that cause an issue with type stability? x = 100randn(100) #Vector{Float64} x = round.(Int, x) #Vector{Int…

---

## [PyCall and email get\_payload](https://discourse.julialang.org/t/pycall-and-email-get-payload/3005)

<div class="topic-metadata">

**Author:** [@KajWiik](https://discourse.julialang.org/u/KajWiik)\
**Replies:** 2\
**Last updated:** [April 2, 2017, 9:24am UTC](https://discourse.julialang.org/t/pycall-and-email-get-payload/3005 "2017-04-02T09:24:33Z")

</div>

I am trying to decode email body using PyCall and email Python library. This works in Python: \>\>\> import email \>\>\> email\_message = email.message\_from\_string(data\[0\]\[1\]) \>\>\> email\_message.get\_payload(decode=True) The pr…

---

## [What's a \[good\] way to make slow Julia code (with no side-effects)?](https://discourse.julialang.org/t/whats-a-good-way-to-make-slow-julia-code-with-no-side-effects/1341)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 1\
**Last updated:** [April 2, 2017, 2:11am UTC](https://discourse.julialang.org/t/whats-a-good-way-to-make-slow-julia-code-with-no-side-effects/1341 "2017-04-02T02:11:24Z")

</div>

\[I was trying to prove to myself that left side of && is always run (unnecessarily, when right one hard-coded to return false).\] slow(n) = begin for i in 1:n end; return true end # Gets optimized away, Julia scores poin…

---

## [\`sparsevec\` operations](https://discourse.julialang.org/t/sparsevec-operations/756)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 2\
**Last updated:** [April 1, 2017, 10:59pm UTC](https://discourse.julialang.org/t/sparsevec-operations/756 "2017-04-01T22:59:23Z")

</div>

Is this intended behaviour? b = sparsevec(\[1\], \[1.0\], 10) typeof(b \* b') # Array{Float64,2} instead of SparseMatrixCSC

---

## [Stably indexed table](https://discourse.julialang.org/t/stably-indexed-table/2989)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 10\
**Last updated:** [April 1, 2017, 6:52pm UTC](https://discourse.julialang.org/t/stably-indexed-table/2989 "2017-04-01T18:52:50Z")

</div>

Out of all the modules for dataframe-like structures (is there a list?), is there one where table\[:col\] or table\[Val{:col}\] is type-stable? As JMW put it: A second possible solution is to generate custom DataFrame type…

---

## [Fatal Error : OutOfMemoryError() in libjulia/c-api not in console](https://discourse.julialang.org/t/fatal-error-outofmemoryerror-in-libjulia-c-api-not-in-console/2662)

<div class="topic-metadata">

**Author:** [@Maxime\_Coorevits](https://discourse.julialang.org/u/Maxime_Coorevits)\
**Replies:** 0\
**Last updated:** [March 14, 2017, 12:41pm UTC](https://discourse.julialang.org/t/fatal-error-outofmemoryerror-in-libjulia-c-api-not-in-console/2662 "2017-03-14T12:41:30Z")

</div>

I’ve a strange fatal error using the ACME.jl package. When I use the package with the libjulia api (c-api), I get a fatal error / out of memory while the same usage in the julia console do not produce any error. I don’…

---

## [Correct usage of SharedArray and @parallel?](https://discourse.julialang.org/t/correct-usage-of-sharedarray-and-parallel/2979)

<div class="topic-metadata">

**Author:** [@xiaoweiz](https://discourse.julialang.org/u/xiaoweiz)\
**Replies:** 3\
**Last updated:** [April 1, 2017, 12:24pm UTC](https://discourse.julialang.org/t/correct-usage-of-sharedarray-and-parallel/2979 "2017-04-01T12:24:08Z")

</div>

In defining a function, I created a SharedArray and use @parallel to fill each of its elements. At last, I want to return the mean of these elements by calling mean on the SharedArray. However, it doesn’t seem to work as…

---

## [Warning: Method definition. Simple explanation please](https://discourse.julialang.org/t/warning-method-definition-simple-explanation-please/2997)

<div class="topic-metadata">

**Author:** [@samsamsam](https://discourse.julialang.org/u/samsamsam)\
**Replies:** 5\
**Last updated:** [April 1, 2017, 10:29am UTC](https://discourse.julialang.org/t/warning-method-definition-simple-explanation-please/2997 "2017-04-01T10:29:57Z")

</div>

Hi, I’m totally new to Julia, and I was hoping for a simple explanation of the error in the title of this post. Other posts I’ve read say something about conditionally defining functions. But I’m encountering this error…

---

## [Deserialize composite type from JSON](https://discourse.julialang.org/t/deserialize-composite-type-from-json/1056)

<div class="topic-metadata">

**Author:** [@josefsachs](https://discourse.julialang.org/u/josefsachs)\
**Replies:** 2\
**Last updated:** [April 1, 2017, 2:40am UTC](https://discourse.julialang.org/t/deserialize-composite-type-from-json/1056 "2017-04-01T02:40:14Z")

</div>

Continuing the discussion from Serializing composite type to json: What is the closest that I can come to deserializing a composite type from JSON? I would like to be able to do something akin to deserialize(Foo, JSON…

---

## [Testing for docstring](https://discourse.julialang.org/t/testing-for-docstring/2992)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [March 31, 2017, 6:26pm UTC](https://discourse.julialang.org/t/testing-for-docstring/2992 "2017-03-31T18:26:33Z")

</div>

How can I test that a macro assigns the right docstring to an object? MWE (without the macro, just the test): "My docstring" immutable MyType end @doc(MyType) == doc"My docstring" # false, how can I make it true?

---

## [Julia -L invocation equivalent to julia -e (for CI)](https://discourse.julialang.org/t/julia-l-invocation-equivalent-to-julia-e-for-ci/2982)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [March 31, 2017, 10:46am UTC](https://discourse.julialang.org/t/julia-l-invocation-equivalent-to-julia-e-for-ci/2982 "2017-03-31T10:46:17Z")

</div>

My script line in .travis.yml is getting too long (checking out master versions, unregistered packages, etc). I would like to replace julia -e 'tons of stuff' with julia -L test-script.jl and move all the commands to…

---

## [How to write .NL file containing JuMP problem using AmplNLWriter.jl](https://discourse.julialang.org/t/how-to-write-nl-file-containing-jump-problem-using-amplnlwriter-jl/2954)

<div class="topic-metadata">

**Author:** [@lruthotto](https://discourse.julialang.org/u/lruthotto)\
**Replies:** 8\
**Last updated:** [March 31, 2017, 3:05am UTC](https://discourse.julialang.org/t/how-to-write-nl-file-containing-jump-problem-using-amplnlwriter-jl/2954 "2017-03-31T03:05:19Z")

</div>

I’m looking for ways to write a jump model to my hard drive so that it can be solved on another machine. julia\> using JuMP, AmplNLWriter julia\> m = Model(solver=AmplNLSolver("bonmin")) julia\> @variable(m,x\[1:2\]) julia\> …

---

## [Recursive type union](https://discourse.julialang.org/t/recursive-type-union/2972)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 9\
**Last updated:** [March 31, 2017, 12:36am UTC](https://discourse.julialang.org/t/recursive-type-union/2972 "2017-03-31T00:36:00Z")

</div>

Is there any way to express “X is an Int, or a Tuple of X” in Julia? const MyT = Union{Int, NTuple{2, MyT}} fails because MyT is not in scope. I tried the Y-Combinator, but Julia doesn’t like (X{X} where X) either, so …

---

## [Is it possible to use "←" for assignment?](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973)

<div class="topic-metadata">

**Author:** [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Replies:** 7\
**Last updated:** [March 30, 2017, 9:52pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973 "2017-03-30T21:52:27Z")

</div>

Recently I was implementing some code following a paper that used the notation “←” for assignment, e.g. a ← b + c Since this is a common notation in computer science, it would be useful to be able to use this in Julia …

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=1054)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=1056)
