How to do multiple imports in Python?
import lib1, lib2, lib3, lib4, lib5
Try this:
import lib1, lib2, lib3, lib4, lib5
You can also change the name they are imported under in this way, like so:
import lib1 as l1, lib2 as l2, lib3, lib4 as l4, lib5
if you want multi-line:
from englishapps.multiple.mainfile import (
create_multiple_,
get_data_for_multiple
)
For known module, just separate them by commas:
import lib1, lib2, lib3, lib4, lib5
If you really need to programmatically import based on dynamic variables, a literal translation of your ruby would be:
modnames = "lib1 lib2 lib3 lib4 lib5".split()
for lib in modnames:
globals()[lib] = __import__(lib)
Though there's no need for this in your example.