Article 52N4C Choosing a style when referring to modules in Python

Choosing a style when referring to modules in Python

by
Turbocapitalist
from LinuxQuestions.org on (#52N4C)
When writing in Python, which style is prefereable when using modules?

In one style you could use them like this:

Code:. . .
from multiprocessing import Process, Value, Array
. . .
w=Value('i')
. . .With another style you could use them like this:

Code:. . .
import multiprocessing
. . .
w=multiprocessing.Value('i')
. . .Is either style preferable? I'm guessing the second example would be preferable because it is less ambiguous which module is in use. What kind of difference is there in regards to cluttering either source code or memory? Maybe it makes more of a difference in longer scripts as opposed to shorter ones.latest?d=yIl2AUoC8zA latest?i=0vKJUOenVm4:HQznGYJB8f8:F7zBnMy latest?i=0vKJUOenVm4:HQznGYJB8f8:V_sGLiP latest?d=qj6IDK7rITs latest?i=0vKJUOenVm4:HQznGYJB8f8:gIN9vFw0vKJUOenVm4
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments