Better HN
topnewbestaskshowjobs
Log inSign up

jnkle

5 karma · joined Dec 9, 2019 (6y ago) · 1 submissions

Submissions

comment 6y ago · link · parent

A couple of interesting capabilities in this post. The section "Controlling What Can Be Imported and What Not" is wrong or misleading though. The dunder __all__ only limits wildcard imports like `from my_module import * `. In your example both `foo` and `bar` can be imported/accessed like `from my_module import foo, bar` or `import my_module; my_module.foo(); my_module.bar()`.

Edit: Also just tried to `import * ` with `_all__ = []` and no AttributeError is raised as is stated. Python 3.7.4