# Module not reading properly

**URL:** https://discourse.julialang.org/t/module-not-reading-properly/41438
**Category:** New to Julia
**Created:** [June 15, 2020, 12:49pm UTC](https://discourse.julialang.org/t/module-not-reading-properly/41438 "2020-06-15T12:49:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [June 15, 2020, 12:49pm UTC](https://discourse.julialang.org/t/module-not-reading-properly/41438/1 "2020-06-15T12:49:52Z")

</div>

The use of modules in Julia is painful for me, after using many languages. However, I am persevering.

In a file `pickle.jl`, I have the following code:

```julia
module Pickle
export mypickle, myunpickle

using PyCall
@pyimport pickle

function mypickle(filename, obj)
    out = open(filename,"w")
    pickle.dump(obj, out)
    close(out)
end

function myunpickle(filename)
    r = nothing
    @pywith pybuiltin("open")(filename,"rb") as f begin
        r = pickle.load(f)
    end
    return r
end

end

```

I `include this file from `main.jl`:

```julia
include("pickle.jl")

```

and get the error:

```julia
julia> include("pickle.jl")
ERROR: LoadError: syntax: extra token "Pickle" after end of expression
Stacktrace:
 [1] top-level scope at /Users/erlebach/covid_modeling_julia/julia_code/sir-julia/notebook/SIRsims/gordon_julia_code/household_workplaces_leon/pickle.jl:1
 [2] include(::String) at ./client.jl:439
 [3] top-level scope at none:0
in expression starting at /Users/erlebach/covid_modeling_julia/julia_code/sir-julia/notebook/SIRsims/gordon_julia_code/household_workplaces_leon/pickle.jl:1

julia> 

```

Am I doing something obviously wrong? I do not see it.

---

<div class="post-metadata">

### Author: ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)
#### Post date: [June 15, 2020, 1:04pm UTC](https://discourse.julialang.org/t/module-not-reading-properly/41438/2 "2020-06-15T13:04:00Z")

</div>

I don’t think this is correct:

```julia
    @pywith pybuiltin("open")(filename,"rb") as f begin
        r = pickle.load(f)
    end

```

I think it should be either:

```julia
    @pywith pybuiltin("open")(filename,"rb") as f
        r = pickle.load(f)
    end

```

Or maybe:

```julia
    @pywith begin 
        pybuiltin("open")(filename,"rb") as f
            r = pickle.load(f)
       end
    end
```

---

<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: [June 15, 2020, 2:11pm UTC](https://discourse.julialang.org/t/module-not-reading-properly/41438/3 "2020-06-15T14:11:40Z")

</div>

I ran exactly the code you posted, both by pasting it into the REPL and using `include()`, and I cannot reproduce the error. Are you sure you’ve posted exactly the code that you are running? Can you try starting `julia` and then pasting your exact module definition from this post?

---

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [June 15, 2020, 5:44pm UTC](https://discourse.julialang.org/t/module-not-reading-properly/41438/4 "2020-06-15T17:44:49Z")

</div>

I am sure. After fixing some problems with Atom/Juno, I am back in business. I did as you suggested, and it worked! So the problem must have been a hidden character. I had copy/pasted the code from some website. Thank you for the advice.
