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!
Answers:
use them like this : from tkinter import Frame , Canvas
You could just import them separated by comma like this:
from tkinter import Frame, Canvas
For more information look at this comment.
Use this
from pandas import (
DataFrame,
crosstab,
set_option
)
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!
use them like this : from tkinter import Frame , Canvas
You could just import them separated by comma like this:
from tkinter import Frame, Canvas
For more information look at this comment.
Use this
from pandas import (
DataFrame,
crosstab,
set_option
)