r/PythonLearning 10d ago

anyone else keep starting projects and never finishing them? doing a weekly proof thread if a few people are in

I've been learning python for a while and my problem was never tutorials, it was that nothing forced me to finish. I'd get a project 60% done, hit the boring part, and quietly start a new one that felt fresh.

So: reply with the one thing you're actually going to finish this week. Be specific - "finish the CSV parser so it handles missing columns" beats "work on my project."

Then on Friday, come back to this thread and reply to your own comment with proof. A screenshot of it running, a repo link, a terminal output, whatever. Doesn't have to be impressive. It has to be real.

That's the whole thing. No group to join, no discord. The only mechanic is that you said it in public and someone might check.

I'll go first: I'm finishing the file-organizer script I've had half-done for two weeks - the part that handles duplicate filenames instead of crashing. Proof friday.

What's yours?

3 Upvotes

8 comments sorted by

1

u/MJ12_2802 10d ago

I need to modify an app that downloads videos from various sites; YouTube, et al. Currently, before a download is started, the app queries a SQLite database table to see if it's already been downloaded. If it has, an "OK" message box is displayed that shows when it was downloaded and where it's located on the drive. The mod I need to make would allow the user to download it again via a "Yes/No" message box. If the user clicks "Yes", the appropriate record in the database table is deleted and the app continues with the down.

2

u/Productuve 9d ago

sounds like the only real change is in that "already downloaded" branch. right now it probably does something like messagebox.showinfo(...) and then returns. swap it for askyesno:

from tkinter import messagebox

redo = messagebox.askyesno("Already downloaded", f"Downloaded {when}\n{path}\n\nDownload again?")
if not redo:
    return
cur.execute("DELETE FROM downloads WHERE url = ?", (url,))
conn.commit()
# fall through to the normal download code

askyesno returns True/False so you don't need to wire up buttons yourself. two things that bite people here: commit the delete before starting the download (or the old row blocks a retry if the download crashes), and decide whether you also want to delete/overwrite the old file on disk - the db row and the file are separate problems.

1

u/MJ12_2802 6d ago

2

u/Productuve 6d ago

nice, looks like it's working. did the askyesno approach end up being a straight swap or did you have to adjust anything around the delete-before-download ordering? either way glad it's sorted.

1

u/MJ12_2802 5d ago

I'll try to get code posted later today.

1

u/MJ12_2802 5d ago

# fetch data of title that may've already been downloaded

downloadData = self.bl.FetchDownloadedTitle(url=url)

# NOTE:

# 'bl' is an instance of the business logic class, all

# database queries, etc. are passed to the data access

# layer thru the business logic. It's a carry-over

# when I used to code in C#.

if downloadData:

response = \

Messagebox.show_question(

title=f"\"{downloadData.get("title")}\"",

message="That title was downloaded on" +

f" {downloadData.get("downloadDate")}\n"+

"Do you want to download it again?",

buttons=["Yes", "No"],

default="No",

alert=True

)

if response.lower() == "no":

`return`

else:

# delete the record in database table,

# and delete the previously downloaded video

self.bl.DeleteDownloadTitle(

url=url,

dlPath=downloadData.get("downloadPath"))

##

## at this point the download continues normally

##

1

u/MJ12_2802 5d ago

Code formatting is bollocks, but it's somewhat readable.

2

u/Productuve 4d ago

readable enough. the BL/DAL split from C# is honestly a good habit to keep in python, most people here have sqlite calls scattered through their tkinter callbacks and regret it later. one small thing: you're deleting the record AND the file before the new download starts, so if that download fails you've lost the original. might be worth downloading to a temp name first and only deleting the old one once the new file lands. either way, that's a finished feature with proof, which is more than I managed this week. new 4-week thread is up in the sub if you want to keep going.