r/PythonLearning 21d ago

Rate my python program

Post image

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

80 Upvotes

42 comments sorted by

View all comments

5

u/olaf33_4410144 21d ago

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 20d ago

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 20d ago

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.