9121
Off Topic / Re: Any Python pros out there willing to clean my code?
« on: May 24, 2013, 10:22:52 PM »
I thought these forums were lurking with Pythoneers. I guess not.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Actually, IIRC, one-minute bans don't expire correctly but get removed from the banlist - meaning that you're effectively permabanned through a glitch but it's impossible to unban you.
from tkinter import *
import time, sys, getpass
database = {}
database["admin"] = "123"
database["user"] = "000"
logged = 'false'
listcommands = (
"Logout, Quit, Removal(Admins Only)"
)
def main():
while True:
print("Say 'help' for a list of commands.")
command = input(">>").lower()
if command == 'help':
print(listcommands)
elif command == 'quit':
quitter()
elif command == 'logout':
logout()
else:
print("Command not valid")
def main2():
print("Welcome! Login, register or quit.")
while True:
command2 = input(">>").lower()
if command2 == "login":
login()
elif command2 == "register":
register()
elif command2 == "quit":
quitter()
else:
print("Command not valid")
def login():
print("Please login.")
while True:
username = input("Username: ").lower()
password = getpass.getpass("Password: ")
if username in database.keys():
expected_password = database[username]
if expected_password == password:
print("Welcome " + username)
global logged
logged = 'true'
main()
else:
print("Login is incorrect. Try again.")
else:
print("User does not exit. Try again.")
def register():
print("Register your information")
time.sleep(1)
newuser = input("Username: ").lower()
newpass = getpass.getpass("Password: ")
database[newuser] = newpass
print("Successful!")
main2()
def quitter():
print("Are you sure you want to quit? Y/N?")
while True:
commandquit = input(">>").lower()
if commandquit == "y":
print("Quitting...")
time.sleep(2)
sys.exit(0)
elif commandquit == "n":
print("Returning to main board...")
global logged
if logged == "true":
time.sleep(1)
main()
else:
time.sleep(1)
main2()
else:
print("Command not valid.")
def removal():
print("Work in progress...")
time.sleep(1)
main()
def logout():
print("Are you sure you want to log out? Y/N")
while True:
commandlogout = input(">>").lower()
if commandlogout == "y":
print("Logging out...")
time.sleep(1)
main2()
elif commandlogout == "n":
print("Returning to main board...")
time.sleep(2)
main()
else:
print("Command not valid.")
app = Tk() # Trying to put it into a GUI here. Too tired to do it at this moment
app.title("Python Test")
label = Label(app, text="Python Test Label").pack()
button = Button(app, text="Login",command=lambda: main2()).pack()
app.geometry("500x300")
app.mainloop()
I don't care about the photo, I'm just trying to forget with him. Because I'm a richard.
12
ill be 12 in 4 years though
There's 2 lanes of life. I drive down the middle and swerve.
50 /50 chance ima make it in this world.
I've got an i5 and a gtx 780. I 100% stand by what I said. You are not going to get a good gaming laptop for under 1k. You can have a mediocre one, sure, but he specifically asks for a GOOD gaming laptop. Anything that is note-worthy is over 1k.
was that supposed to be a comeback
This
http://www.newegg.com/Product/Product.aspx?Item=N82E16834312438
You're absolutely loving handicapped.
"If something bad happens to you on your computer or in real life that is off-topic, not drama. "
This is on a computer, he was saying that things that happen in real life are not to be posted here