jonwright / pyopengltk

OpenGL frame for Python/Tkinter via ctypes and pyopengl
MIT License
54 stars 13 forks source link

Basic Example remove "tkinter." #22

Closed ShaunKulesa closed 3 years ago

ShaunKulesa commented 3 years ago

if you do from tkinter import * you wont have to do root = tkinter.Tk() instead you can do root = Tk()

einarf commented 3 years ago

I would avoid star imports because it really pollutes the module. It's not really recommended.

You can import specific objects or shorten the imported module name instead

# Shorten the imported module name
import tkinter as tk
tk.Tk()
# Import specific objects
from tkinter import Tk
Tk()

It can make sense in some cases, but it gets messy as programs grow. Code inspection tools and linters are not a fan of star imports.