include A python file that exisist in the project -
im totaly new python in absolute beginner stage. know alot php mind think in php way when trying stuff python.
i have python project contains a:
test.py
includes(folder)
- math.py
the test.py contains code:
import mysqldb db = mysqldb.connect(host="127.0.0.1", user="root", passwd="", db="python") tkinter import * root = tk() root.title("test") root.geometry("500x500") window = frame(root) window.grid() label = label(text="") label.grid() def click(): cur = db.cursor() query = cur.execute("select * names") result = cur.fetchall() label["text"] = result[0] b1 = button(window, text = "click me!",command=click) b1.grid() root.mainloop()
how include math.py file can use class inside. know in php it's:
include("indcludes/math.py");
but how make same thing in python, if posible @ ;)
ty time.
create empty file called __init__.py in includes
folder.
$ touch includes/__init__.py
in client code test.py
, import math.py class through
from includes import math
Comments
Post a Comment