# Revise and import

**URL:** <https://discourse.julialang.org/t/revise-and-import/23319>\
**Category:** General Usage\
**Created:** [April 19, 2019, 6:29pm UTC](https://discourse.julialang.org/t/revise-and-import/23319 "2019-04-19T18:29:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhazeghi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhazeghi/32/7107_2.png) [@dhazeghi](https://discourse.julialang.org/u/dhazeghi)\
**Post date:** [April 19, 2019, 6:29pm UTC](https://discourse.julialang.org/t/revise-and-import/23319/1 "2019-04-19T18:29:28Z")

</div>

Hi folks,

a fairly basic question on Revise.jl usage: how should I use revise with packages (mine) that import other packages? For example:

```julia
julia> using Revise
julia> import MyPackage
<edit code in package imported by MyPackage>
julia> MyPackage.function()
<old code is run>

```

I tried adding ‘using Revise’ to MyPackage, but that didn’t seem to have any effect either. Thanks,

Dara

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [April 19, 2019, 7:25pm UTC](https://discourse.julialang.org/t/revise-and-import/23319/2 "2019-04-19T19:25:08Z")

</div>

Your approach _should_ work. However, note that `using Revise` must come before the package that you’re editing is loaded. Perhaps you already did `using OtherPackageThatMyPackageImports` in this Julia session?

I find it most convenient to just load Revise automatically, which ensures that it is always loaded first: [Configuration · Revise.jl](https://timholy.github.io/Revise.jl/stable/config/#Using-Revise-by-default-1)

---

<div class="post-metadata">

**Author:** ![LudiWin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ludiwin/32/9163_2.png) [@LudiWin](https://discourse.julialang.org/u/LudiWin)\
**Post date:** [May 7, 2020, 11:23am UTC](https://discourse.julialang.org/t/revise-and-import/23319/3 "2020-05-07T11:23:04Z")

</div>

I think my question is a suitable follow-up question:

When using Revise and importing a module , Revise does its magic.  
More specifically I can redefine the struct in the imported module and Revise reloads it.

But when importing a specific struct/function from the module, I get a LoadError: MethodError.  
Is there some syntactic difference to what Revise can reload and what not?

Example:

```julia
# Both files Human.jl and Main.jl are in the same directory

# Human.jl

module Human

export Person, printastring

struct Person
    name::String
    age::Int64
    zip::Int64
    partner::Bool
    child::Bool
end
end

# Main.jl

using Revise
include("Human.jl")
import .Human: Person

Bob = Human.Person("Robert", 16, 12345, true, false) -> Revise works
Bob = Person("Robert", 16, 12345, true, false) -> Revise doesnt work
println(Bob)

```

Specifically, my question is how Revise interacts with importing functions/structs from modules and what the best practices are for Revise and importing specific functions/structs from other modules.

---

<div class="post-metadata">

**Author:** ![LudiWin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ludiwin/32/9163_2.png) [@LudiWin](https://discourse.julialang.org/u/LudiWin)\
**Post date:** [May 9, 2020, 12:52pm UTC](https://discourse.julialang.org/t/revise-and-import/23319/4 "2020-05-09T12:52:12Z")

</div>

There is actually an entire paragraph on how to use Revise with import and all in the official Julia docs:

[https://docs.julialang.org/en/v1/manual/workflow-tips/#Browser-based-workflow-1](https://docs.julialang.org/en/v1/manual/workflow-tips/#Browser-based-workflow-1)
