Skip to content

include file containing module #2849

@dorn-gerhard

Description

@dorn-gerhard

Hi,
I wanted to ask for a best practise for including a self-written module MyModule.jl and having all
exported functions (my_function) within the workspace of the Pluto notebook available instead of MyModule.my_function

Workaround would be of course to create a package.

But relating to #115 it would be cool to first load the file ingredient("./MyModule.jl") and then use the module with all exported functions.

Interestingly using .MyModule or using .MyModule: my_function is not working.
When using include("MyModule.jl")
using .MyModule is not working but using .MyModule: my_function is working (see video below).

So I thought what about creating a function that loads all my exported functions (names(MyModule)):

function using_local_module(modulename)
	return eval(Meta.parse("using " * string(modulename) * """: """ * join(string.(modulname), ", ")))
end

but that does only work in the same cell.

So what is the best way to use a self-written module saved in a file.jl within Pluto?

2024-03-13.20.31.25.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions