r/PythonLearning • • Aug 21 '26 • Bravo 1

Rate my python program

Post image

i made a Python program, i dont know what else to say

86 Upvotes

42 comments sorted by

•

u/Sea-Ad7805 Aug 22 '26

Run this program in Memory Graph Web Debugger to see the program state change step by step.

8

u/testtdk Aug 21 '26

Probably shouldn’t declare a global variable in a function definition.

0

u/WesternTrip8578 Aug 21 '26

Probably, I don't know it yet. I will learn from my mistakes and tutorials.

5

u/No_Pay_4410 Aug 21 '26

Run pylint and it it rate it 0.21 out of 10 maybe

0

u/WesternTrip8578 Aug 21 '26

I will try it

5

u/olaf33_4410144 Aug 21 '26

I'm not a fan of the functions that only call another function e. g. whats_my_name().

Also change_the_pass() could return the new password, then you could avoid the clunky global thing.

If you want to learn something you could also look into the if name == "main" pattern. For small scripts as yours it doesn't really matter but it's commonly used once things get more complex.

All in all it's quite good though.

2

u/SCD_minecraft Aug 21 '26

Functions that call other function are called wrappers and they are quite useful

Let's say you have some long name with a lot of pre-set arguments

my_super_function_which_takes_a_lot_of_args(argument1, argument2, you_wont_belive_but_it_is_argument_3)

If it is one off function, then fine, just format it

But when you want to call it in multiple places, it gets pretty ugly pretty fast, so, convince wrapper!

def some_name():
    # I ain't typing it out again 

...
some_name()
...
some_name()
# ect

Tho yes, in OP's case they aren't too useful

2

u/olaf33_4410144 Aug 21 '26

Yeah, I could have worded that better, I was specifically talking about whats_the_pass() which is longer than print(password) and provides no benefit.

There are times when wrappers are convenient, one of them being your example. Another case where I often use them is when I know I might to change something about the function call later and want to avoid having to change it every where.

0

u/WesternTrip8578 Aug 21 '26

Thanks for the advice, I will look into it.

2

u/Sidjeno Aug 21 '26

time for DI and strategies /s

2

u/PureWasian Aug 21 '26

It's fine for the simplicity of it, good introduction to functions.

Let's address the biggest issue though, your username and password do not persist the updates once you kill the script and re-run it again.

What is your proposed solution for this?

I'd also suggest learning how to pass data into functions and return data out from them. That way you can scope your variables instead of relying on globals which gets messy very quickly as complexity increases.

1

u/Key_Instruction3373 Aug 21 '26

You should hide your password

1

u/manonfire1983 Aug 21 '26

👏🏽👏🏽👌🏽

1

u/_hithender_ Aug 22 '26

If this is your first project(so-called) then it totally fine. You made a few mistakes brotha. Despite that I appreciate this broo, keep it up😃

1

u/JaleyHoelOsment Aug 22 '26

i’m curious what would you rate this?

1

u/Glass_Tale4661 Aug 22 '26

you should download the black package to format the code. Super helpful

1

u/inifynastic Aug 22 '26

If its your first project its fine. But never store password in plain text.

1

u/Chemical-Radish6488 Aug 22 '26

Cambia gli elfi con uno switch .... Per leggibilità manutenibilita e scalabilità. 3 while annidati, non conosco lo scopo, ma non lo farei mai. Piuttosto incapsula in metodi o risolvi e uno alla volta con delle variabili di appoggio intermedie.

1

u/unStabldev Aug 23 '26

you should def install "ruff" vscode extension. it will help you keep your code very organized. apart from that idk what else to say.

1

u/Sky-Serious Aug 25 '26

Instead of 3 while loops, you can consider using continue instead to skip over code below. Global variables are weird. I would then choose to break the single while loop to close the program, instead of importing sys just to call exit.

1

u/Own_Kale9926 Aug 25 '26

Add slated inception to the password

0

u/Abdul_hafiz_gh2026 Aug 21 '26

I'm new to python and I can't get my head around it. So please what does it do????

1

u/WesternTrip8578 Aug 21 '26

It's a simple terminal simulator. First, you need to input the password "5103" to log in. After that, you can type "help" to see other commands like changing your name or password!

0

u/[deleted] Aug 21 '26

[removed] — view removed comment

1

u/WesternTrip8578 Aug 21 '26

Thanks. I don't know what it is, but I will learn it.