JuliaPy / JuliaPy/PythonCall.jl

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

Offen
#590 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Julia
Sterne
1.1k
Forks
86
Ø Merge
1 T. 22 Std.
Gemergte PRs (30 T.)
3

Beschreibung

With these methods:

```julia
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
```julia
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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.