Can anyone suggest me what is the most pythonic way to import modules in python? Let me explain - i have read a lot of python code and found several different ways of how t
Do not use from module import *. This will pollute the namespace and is highly frowned upon. However, you can import specific things using from; from module import something. This keeps the namespace clean. On larger projects if you use a wildcard you could be importing 2 foo or 2 bar into the same namespace.
PEP 8 says to have imports on separate lines. For instance:
import os
import sys
import yourmodule
from yourmodule import specific_stuff
One thing I do is alphabetize my imports into two groups. One is std/third party and the second is internal modules.