Closed tomitokko closed 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).
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 singleexpenses
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 callingmain()
at the end), or further modify code to give ability to fully work as script and as an import (mostly that means not using globalexpenses
, 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.
Checklist:
Update index.md
)Closes #XXXXX
Added the expense tracker project