0

Oop login code

Hi, I'm looking to create a oop work management tool, my first screen is the login but I've hit a block on how should i start this. Any help please?

5th Nov 2021, 10:28 PM
Shan Raza
Shan Raza - avatar
10 Antworten
+ 3
oop is about making objects so you could start with deciding what classes you are going to make and for what purpose they will be made for.
5th Nov 2021, 11:36 PM
Slick
Slick - avatar
+ 1
You'd need to go through the filehandling section here, but its fairly simple. The hard part is writing the data so its easy to read. Cause you'd have to code that too
11th Nov 2021, 9:23 PM
Slick
Slick - avatar
0
Thanks, in this scenario my class would be just be User. class User(): def __init__(self, username, password, email): self.username = username self.password = password self.email = email def login(self, username, password): self.username = input("Enter username: ") self.password = input("Enter password: ") with open("register.txt", "r", encoding=utf-8) as file: if username == username and password == password: print("login successful!") Would this be sufficient?
6th Nov 2021, 4:36 AM
Shan Raza
Shan Raza - avatar
0
Not really, cause it seems like you want to keep a database text file of usernames and passwords. But your code opens up a file to read it and does nothing with it. Then it compares 2 strings against themselves so it will ALWAYS print out "login successful"
6th Nov 2021, 11:17 AM
Slick
Slick - avatar
0
How would i give an error if either does not match with the name and passwords stored in a file?
7th Nov 2021, 5:00 AM
Shan Raza
Shan Raza - avatar
0
How would i save the details to a new file?
11th Nov 2021, 9:22 PM
Shan Raza
Shan Raza - avatar
0
I've gone through the sections and whilst i understand it, when it comes to writing the code i seem to get stuck. This had been the case for every aspect of my project as well.
11th Nov 2021, 9:35 PM
Shan Raza
Shan Raza - avatar
0
trial and error is your friend! Also try writing out some code and then bring that to us
11th Nov 2021, 9:42 PM
Slick
Slick - avatar
0
Hi guys, i manged to create a screen and connect to sqlite3 db but when i run the code the text is not visble in the gui screen and typerror. missing 1 required positional argumemt. any advise? i didn't include an __init__ method, could this be the issue?
15th Nov 2021, 8:55 PM
Shan Raza
Shan Raza - avatar
0
it's very possible you didn't include the "self" parameter in your __init__ definition
15th Nov 2021, 10:17 PM
Slick
Slick - avatar