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:
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`:
include("pickle.jl")
and get the error:
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.