Andrew Graham-Yooll
Andrew Graham-Yooll

Reputation: 2258

Is it possible to do "from module.foo import * as bar" in python?

In javascript I can import * as bar from 'moduleFoo'.

Is there an analogous method in Python3?

Upvotes: 1

Views: 67

Answers (1)

user2357112
user2357112

Reputation: 280500

import moduleFoo as bar

You may not need the as bar, though. Unlike in Javascript, import moduleFoo already inserts the moduleFoo module object into the current namespace under the name moduleFoo, containing all bindings defined in the module.

Upvotes: 2

Related Questions