I am writing a program in python. I am using about a dozen modules. Currently I have placed them in the functions themselves. My reasoning is that since a user is not going to use all the functions in a session, many modules don't have to be imported uselessly until a function requires them. But all the code I have seen till now have their imports at the beginning. What are their reasons and advantages?
Also what is the best way to import ? I have seen several types like:
from tkinter import *and thenLabel(),Tk()import tkinterand thentkinter.Label(),tkinter.Tk()import tkinter as tkand thentk.Label()?
What's the best way? I see first one is shortest. Is it also the best?