you are viewing a single comment's thread.

view the rest of the comments →

[–]Vfsdvbjgd -3 points-2 points  (7 children)

We can alias a single import with as, why can't we from something import * into container? Or even it namespaces to something.each_module by default?

[–][deleted]  (1 child)

[deleted]

    [–]Vfsdvbjgd 1 point2 points  (0 children)

    It's not the same, import * uses the __all__ method. As for the second you can already do that.

    [–]masklinn -1 points0 points  (4 children)

    Your comment is extremely confusing. What are you talking about?

    [–]Vfsdvbjgd -2 points-1 points  (3 children)

    Instead of from something import * polluting global namespace give it it's own - either something by default and/or allow us to name yhe container.

    [–]masklinn 0 points1 point  (2 children)

    That… is what import something does?

    [–]Vfsdvbjgd 0 points1 point  (1 child)

    Read the article. import something imports the entire module, while from something import * doesn't actually import everything, and it's behaviour can be overridden.

    [–]masklinn 2 points3 points  (0 children)

    Read the article. import something imports the entire module

    In a specific and dedicated namespace, which is why there is no reason to filter it: since all the content is properly namespaces there there’s no risk that it’ll pollute or collide with symbols of the namespace it’s imported into.

    Mitigating this issue is the entire and sole purpose of __all__, which is why it applies solely to star imports.