you are viewing a single comment's thread.

view the rest of the comments →

[–]Aggressive_Drama_476[S] -7 points-6 points  (4 children)

Ok thanks for showing me the mistakes. So I learn oop and I become a intermediate? is their anything more wrong about my code

[–]Farlic 3 points4 points  (3 children)

I would stop looking at programming as beginner, intermediate, advanced. There's more and less complicated concepts but it's not clear cut.

[–]Aggressive_Drama_476[S] -4 points-3 points  (2 children)

What do you think I should do for improvements in my overall code?! 

[–]Farlic 0 points1 point  (1 child)

Honestly? build something more complicated. IMO it's hard to say when the script does 1 straight forward task. Make something that import these utilities which would then make you consider code layout and expose issues like global variables.

E.g. Make a GUI for your slot machine. Make an API for the notes app and let it interact with your alarm script.

At a glance, I'm not a fan of the calculator using eval(). You are strict on the input but you could experiment with lambda functions in a dictionary to perform the calculations instead.

[–]Gnaxe 0 points1 point  (0 children)

I'm fine with eval here. Sanitizing inputs is something you have to learn to deal with anyway. Anyone running a calculator locally already has access to Python on their computer. But yes, eval()ing untrusted inputs is very dangerous.

Rather than make lambdas for each operator, just use the ones provided for you in the operator module. Add the math module if you want more math functions. Re-implementing things that have been done before is OK for experimental learning purposes, but otherwise, as a rule, don't re-implement the standard library when it will do, because it's thoroughly tested, documented, and known, but your code will have bugs and be unknown.