mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 11:40:18 +01:00
Implement "from module import *" construct.
This commit is contained in:
11
py/runtime.c
11
py/runtime.c
@@ -1016,6 +1016,17 @@ mp_obj_t rt_import_from(mp_obj_t module, qstr name) {
|
||||
return x;
|
||||
}
|
||||
|
||||
void rt_import_all(mp_obj_t module) {
|
||||
DEBUG_printf("import all %p\n", module);
|
||||
|
||||
mp_map_t *map = mp_obj_module_get_globals(module);
|
||||
for (uint i = 0; i < map->alloc; i++) {
|
||||
if (map->table[i].key != MP_OBJ_NULL) {
|
||||
rt_store_name(MP_OBJ_QSTR_VALUE(map->table[i].key), map->table[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mp_map_t *rt_locals_get(void) {
|
||||
return map_locals;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user