You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All though, it may not look like it, they do the exact same thing, and I don't know which one is more reliable (Error handling and simplicity):
defgen_date(self):
start_date=simpledialog.askstring("Set Date Range", "Enter start date (MM/DD/YYYY):")
end_date=simpledialog.askstring("Set Date Range", "Enter end date (MM/DD/YYYY):")
ifstart_dateandend_date:
start_date=datetime.strptime(start_date, "%m/%d/%Y")
end_date=datetime.strptime(end_date, "%m/%d/%Y")
delta= (end_date-start_date).daysrandom_days=random.randint(0, delta)
random_date=start_date+timedelta(days=random_days)
random_date=max(random_date, start_date)
random_date=min(random_date, end_date)
Or
defdate_range(self):
start=simpledialog.askstring("Set Date Range", "Enter start date (MM/DD/YYYY):")
ifstart:
try:
start=datetime.strptime(start, "%m/%d/%Y")
end=simpledialog.askstring("Set Date Range", "Enter end date (MM/DD/YYYY):")
ifend:
end=datetime.strptime(end, "%m/%d/%Y")
ifstart>end:
raiseValueError("Start date must be earlier than end date")
delta= (end-start).daysrandom_days=random.randint(0, delta)
gen_date=end-timedelta(days=random_days)
self.text.insert("insert", gen_date.strftime("%B %d, %Y"))
else:
messagebox.showerror("Error", "End date is required")
exceptValueErrorase:
messagebox.showerror("Error", str(e))
The first one is shorter, but it looks too good to be true. If they both have good error handling, then it should be the one that is shorter.
the first one is 932 characters, the second one is 632.
Character amount matters to me, because I want it to be as little characters as possible, taking up less storage, meaning a larger audience can reach it.
I have tried to remove the question from 1, because I know that 2 will definitely NOT work if just remove the question.
The error I get is:
All though, it may not look like it, they do the exact same thing, and I don't know which one is more reliable (Error handling and simplicity):
Or
The first one is shorter, but it looks too good to be true. If they both have good error handling, then it should be the one that is shorter.
the first one is 932 characters, the second one is 632.
Character amount matters to me, because I want it to be as little characters as possible, taking up less storage, meaning a larger audience can reach it.
I have tried to remove the question from 1, because I know that 2 will definitely NOT work if just remove the question.
The error I get is:
The text was updated successfully, but these errors were encountered: