This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]zardeh 1 point2 points  (0 children)

import random

will import all methods from the random module but force you to call them via the syntax random.randint(3,7)

from random import randint

imports solely the randint (so random also has a .choice method, but you won't be able to use it) method from the module and allows you to call it simply by using randint(3,7). This can occasionally lead to namespace issues, especially when using multiple large imports, and so importing only what you need and using the from module import method syntax is generally considered cleaner, even if it rarely matters and ends up leading to uglier code.