r/PythonLearning • u/Stonyax97 • 5d ago
Showcase I JUST finished my second python project!
Lately I have been working on this ATM For Teens, just to understand OOP and some concepts more (which I REALLY DID)
this isn't meant to be a real ATM (obviously, it's very beginner and not security is there), here is my First project.
So, I have learnt quite a lot since last project, I learnt a bit more about python syntax, I also understood the approach of classes a lot better. I learnt git (just the essentials).
Since I always wanted to Make iPhone apps, and now I have a Mac, I'm thinking whether I should start learning swift and swiftUI, or move to something else, or keep learning python. what do you guys think? I Do want a job as an IT engineer (or anything with coding tbh, cybersec too but that would require C knowledge a bit more lol)
Otherwise, if you guys have any criticism or suggestions for the ATM, then I would be veryyy happy to hear some! here's the repo: https://github.com/Stonyax97/ATM-For-Teens
4
u/Money_Ad_5277 5d ago
It's nice to see someone actually learning!
No hate to you, I was like this a year ago.
Few tips:
don't put everything in main.py, you clearly can extract User class to dedicated file called user.py and import it wherever you want.
Operations with accounts.json should be extracted into a separate class
User class shouldn't have any print statements, throw errors/return results and handle it in your program
Transaction should be separate class, you can apply polymorphism here (abstract base transaction and withdraw/deposit transaction) with repr or str magic methods
Toast - exists. Usually it's a popup, but here it just sleep. I guess it's to mimic real world app? But here you would use async/await to not block user input
Please, use PEP linter, it's painful to see a=b and random empty lines before else/elif - you want to maintain good code readability
if deposit_amount + self.balance > 500:print('You can only have up to $500 in your account')No magic numbers, use static class/env to store them.
Variable naming: cuser, c, etc
Consistency: you know global, but it create_account you referencing global variable accounts, without letting anyone know that it's global variable
raise SystemExit() - bad, there is "break" keyword to exit loops without exiting whole program
I hope some of those tips will help you improve!
Some advanced stuff (DIP, data structures, lambdas)
savemethod - should be separate class, injected into User, to act like a db. You can even try to use mongodb/mysql container running to fully understand async/awaitmain while loop
creating a dictionary like
{
"choise_id": {
"description": "some stuff", action: log_in # log_in is method
}
}
will make your loop significantly smaller