freeCodeCamp / CurriculumExpansion

Creative Commons Attribution Share Alike 4.0 International
313 stars 105 forks source link

Add expense tracker project #365

Closed tomitokko closed 10 months ago

tomitokko commented 10 months ago

Checklist:

Closes #XXXXX

Added the expense tracker project

gikf commented 10 months ago

There's one thing left that can make usage of the script/module a bit awkward. There's if __name__ == "__main__": which shows that code can be used as a standalone script, or be imported from other module. No problems when running it as a single script. However single expenses list makes usage as an import problematic, as for example, it's not going to be possible to create two different lists for two persons.

Therefore I'd recommend to either make it work only as a script (by removing mentioned if and just calling main() at the end), or further modify code to give ability to fully work as script and as an import (mostly that means not using global expenses, but working with list that would be passed to each function).

tomitokko commented 10 months ago

There's one thing left that can make usage of the script/module a bit awkward. There's if __name__ == "__main__": which shows that code can be used as a standalone script, or be imported from other module. No problems when running it as a single script. However single expenses list makes usage as an import problematic, as for example, it's not going to be possible to create two different lists for two persons.

Therefore I'd recommend to either make it work only as a script (by removing mentioned if and just calling main() at the end), or further modify code to give ability to fully work as script and as an import (mostly that means not using global expenses, but working with list that would be passed to each function).

This is a great suggestion, thanks. Instead of just removing the if I have refactored the whole code and it should be good now.