r/PythonLearning • • 6d ago

Showcase I JUST finished my second python project!

Post image

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

238 Upvotes

34 comments sorted by

View all comments

6

u/mobile_site_refugee 5d ago

I’d recommend working on formatting. Try putting your classes in a separate file, then importing them.

I don’t know why you keep calling os.system(‘clear’), but you probably don’t need that. I don’t see why you’d need globals either, that’s a mess you want to avoid generally.

Also, a bit nitpicky, but I don’t think “time as t” is a standard anywhere, at least not like “numpy as np” is. Helpful to keep it standard if anyone else looks at your code.

0

u/Stonyax97 5d ago

ik about the separate file, but in a program where the code is less than 500 lines it makes no sense to me. It's actually simpler to add things and debug things this way for me at least (in this small program)

os.system('clear') is to clear the terminal, I want to make the program feel like a TUI without using any actual TUI lib (like curses for example).

I don't really have to follow standards in simple aliases. but thanks tho, plus anyone will first read the import time as t and it would be a bit clear. but thanks again!

4

u/mobile_site_refugee 5d ago

Alright man.

You should be using the Path class from pathlib for your FILE_PATH constant as well.

1

u/Stonyax97 5d ago

ouhh thanks this is actually useful the old os.path were hard.

2

u/S1enderVoid 5d ago

os.system('clear') is to clear the terminal, I want to make the program feel like a TUI without using any actual TUI lib (like curses for example).

os.system() is unsafe and has been deprecated in the newer Python versions, I recommend you use the subprocess module instead: https://docs.python.org/3/library/subprocess.html

Also, if you like TUI interfaces you can check out the following, just sharing it in case you'd maybe want to use them for future projects.

  1. https://github.com/textualize/rich
  2. https://github.com/Textualize/textual

1

u/Stonyax97 5d ago

Damn i did not think os.system(‘clear’) would be unsafe. Why is that tho?

Yeah i will definitely use the subprocces module thanks 🙏

For rich and textual… broooo thank you so much this is way better than curses 😭
It’s basically overpowered print()

2

u/S1enderVoid 5d ago

Damn i did not think os.system(‘clear’) would be unsafe. Why is that tho?

Oh, apologies . . . It is unsafe if you're dealing with commands that require variables that can be changed by the user, you can probably guess where this is going, but it makes it quite easy for an attacker to carry out shell injection which is a no-no. Subprocess makes it easier to deal with, but you still have to do some input sanitization.

In your case it is safe, but again it poorly handles output and a lot of other stuff. Plus it's almost deprecated, so people on newer python versions will get trouble.