Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My First App
#2
Couple of things, after a brief flight over the code

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/else


https://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
BCopeland64 likes this post
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

Reply


Messages In This Thread
My First App - by BCopeland64 - Feb-13-2023, 09:18 AM
RE: My First App - by buran - Feb-15-2023, 11:57 AM
RE: My First App - by BCopeland64 - Feb-15-2023, 05:46 PM
RE: My First App - by buran - Feb-15-2023, 07:21 PM
RE: My First App - by BCopeland64 - Feb-16-2023, 09:20 AM
RE: My First App - by buran - Feb-16-2023, 11:20 AM
RE: My First App - by BCopeland64 - Feb-16-2023, 11:52 AM
RE: My First App - by BCopeland64 - Feb-16-2023, 08:20 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020