How do you import multiple things in one line using Python?

Question:

Currently I have been importing everything from a module. I recently learned that is bad coding practice, so how do I import multiple things inside a module in one line? This would be useful if I am importing may things from one module.

Right now, I’m trying to figure out how to do this in one line:

from tkinter import Frame
from tkinter import Canvas

Help would be appreciated. Thanks!

Asked By: Enderman

||

Answers:

use them like this : from tkinter import Frame , Canvas

Answered By: ImThePeak

You could just import them separated by comma like this:
from tkinter import Frame, Canvas

For more information look at this comment.

Answered By: Zeephyros

Use this

from pandas import (
    DataFrame, 
    crosstab, 
    set_option
)
Answered By: Maxwell D. Dorliea
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.