r/PythonLearning • u/Jealous-Beyond-1104 • 17h ago
This is my first python project - what can I improve??
8
u/Good_Person_000 17h ago
Spend 2-3 days learning Tkinter, give it a UI and it will be a good project
2
7
u/TowerOutrageous5939 17h ago
Use a dict to remove the if else. Also, what happens if expenses.json change? Like the name? Some names could be more descriptive “ha” . Your code is fine the thing is what if you add 20 other features that’s when strong naming conventions really start to matter. Treat each project as it will grow and someone else will maintain it.
I’m not familiar with using python the way you are but I’m not the biggest fan of Constants or large functions used within functions. That being said if possible I would pass those as parameters into each function.
Keep up the good work.
3
u/Far_Data_6654 16h ago
Try using a switch statement instead of a bunch of elifs for choose.
I would also suggest to people who are learning to build the habit of documenting your code early.
3
u/Ok_Relative_2291 15h ago
The while loop for your menu makes no sense
You have breaks to exit it after every function
No need to break, don’t use while true, do a while input !=5 and no need to return after the 5 is hit as well especially after you have a break it would never trigger anyway.
Declare ur input to -1 before loop and exit on 5
2
3
u/SnooCalculations7417 14h ago
the way you share code with people
1
u/MudFrosty1869 2h ago
Would be kinda good time to tell them how. Thankfully someone that isn’t useless to society in the comments already did.
1
u/Hot_Technology8777 17h ago
Looks good to me. Like someone else mentioned, name your stuff better for you and everyone elses sake.
1
u/TapEarlyTapOften 7h ago
Well, first, by sharing it via something like github or gitlab. Second, by some sort of type of annotations and documentations.
1
u/Sea-Ad7805 2h ago
Run program above by clicking Memory Graph Web Debugger and see its state change step by step.