Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jlapeyre opened this issue Jan 20, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@jlapeyre
Copy link

jlapeyre commented Jan 20, 2025

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.

@jlapeyre jlapeyre added the enhancement New feature or request label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant