How to simplify this to be more small
from tkinter import *
from random import randint
from tkinter import ttk
import tkinter as tk
import random, os
Thanks
CodePudding user response:
Only import them,
import tkinter as tk
import random
import os
then use in code like this,
random.randint
tk.ttk
Updated
But according to best practice use this
import os
from tkinter import *
from tkinter import ttk
from random import randint
CodePudding user response:
constructing on @SAM's answer, you can further reduce a line of code like this:
import tkinter as tk
import random, os
If you want to further make it a 1-liner, then you must perform blasphemy in python: the semicolon
import tkinter as tk; import random, os
CodePudding user response:
I find the answer, thanks
from tkinter import *
import random, os
CodePudding user response:
Keep only one for
random
, one fortkinter
for each choose :
from PACKAGE import STUFF1, STUFF2
: there is not so much imports, and name are easily understandableimport PACKAGE as p
: there is many imports to do from, or import name can be confusing
NEVER USE
*
, always explicit namesFollow community "rules", for mainstream packages
import pandas as pd import numpy as np