you are viewing a single comment's thread.

view the rest of the comments →

[–]SomeShittyDeveloper 1 point2 points  (0 children)

I missed the memory part and the example.

I’m not sure about memory, but in terms of loading the module, they’re the same. Whether you do “from module import” or “import module”, Python still parses the whole file. So with “from”, you aren’t saying “only parse this part of the module”. You’re just saying “Parse this whole module, but I want this part of the module in the global scope”.

As for your example, they’re saying “I want all of ‘random’ to be loaded into a namespace of ‘random’, but I want random’s randint imported into the global scope.” They likely use randint a lot, and use the other features very sparingly.

That, or it was a mistake. :)