pub fn import<M, N>(module: M, name: N) -> Import
Expand description
The import of a Python name from module import foo
.
ยงExamples
use genco::prelude::*;
let toks = quote! {
$(python::import("collections", "namedtuple").with_alias("nt"))
$(python::import("collections", "namedtuple"))
$(python::import("collections", "namedtuple").qualified())
$(python::import("collections", "namedtuple").with_module_alias("c"))
};
assert_eq!(
vec![
"from collections import namedtuple, namedtuple as nt",
"import collections",
"import collections as c",
"",
"nt",
"namedtuple",
"collections.namedtuple",
"c.namedtuple",
],
toks.to_file_vec()?
);