+ 2
Really worth to avoid import *(star) from Python??
I heard I should avoid "import *" as this could cause many problems. So ended up as below: import tkinter from tkinter import messagebox, Frame, filedialog, Pack, Tk, Label, Button, StringVar, Entry from tkinter import BOTH, LEFT, RIGHT, TOP, FLAT, CENTER hmm.. is this the best practice? It doesn't look right. It's too many.
2 Antworten
+ 8
from lib import * has a benefit - you can cast lib's method's without its name, so instead of lib.method() you just write method()
But that's about it, no additional benefits from that. The danger is that if you don't know the lib too well, you might have just overwritten another methods you use, that come as built-ins.
For example, if lib contains a print() method, importing with an asterisk makes the default print() inaccessible :( So heed the warning.
0
You should really just put it. If you just put, from tkinter import, nothing good would happen.