Couple of things, after a brief flight over the code
https://github.com/Bcopeland64/IU-Habit-...ain.py#L70
What is the purpose of
https://github.com/Bcopeland64/IU-Habit-...bit.py#L70
don't change list while iterating over it. Iterate over copy of the list instead:
https://github.com/Bcopeland64/IU-Habit-...ain.py#L70
What is the purpose of
main()
? You never call it and also it repeats the different cli commands - you can always organise it better, e.g. using dict, instead of this huge if/elif/elsehttps://github.com/Bcopeland64/IU-Habit-...bit.py#L70
don't change list while iterating over it. Iterate over copy of the list instead:
for i, completed_at in enumerate(self.completed_at[::]):In all SELECT queries - you will get IndexError if no result is returned (i.e. empty result set), e.g.
self.cursor.execute( 'SELECT id FROM habits WHERE name=?', (name,) ) habit_id = self.cursor.fetchone()[0]if name is not present and fetchone() returns empty tuple, there is no index 0
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs