Skip to content

[Enhancement] Allow Python: <class 'module'> as argument to pyimport #590

Open
@jlapeyre

Description

@jlapeyre

With these methods:

pyimport((m, k)::Pair{Py}) = pyimport(string(m.__name__) => k)
pyimport((m, ks)::Pair{Py,<:Tuple}) = pyimport(string(m.__name__) => ks)

you can do something like

amodule = pyimport("amodule")
afunc = pyimport(amodule.submodule1.submodule2, "afunc")

You can use TAB completion at the REPL to get the submodules. This is more convenient than finding and typing the strings.

I don't know how robust string(m.__name__) is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions