[Python-ideas] Re: timedelta.strptime() and timedelta.strftime()

2023-02-02 Thread Cameron Simpson
On 02Feb2023 21:42, Thomas Mc Kay wrote: I was looking for a simple intuitive way to parse a timedelta from a string. The best I could find feels clunky at best: https://stackoverflow.com/questions/4628122/ Solution 1 looks like this: ``` from datetime import datetime, timedelta t = datetime.

[Python-ideas] Re: timedelta.strptime() and timedelta.strftime()

2023-02-02 Thread Thomas Mc Kay
Here's a fourth way I've seen, that I forgot to mention (mostly a variation of Solution 2, above): ``` delta = datetime.strptime('05:20:25', '%H:%M:%S') - datetime.strptime('00:00:00', '%H:%M:%S') ``` ___ Python-ideas mailing list -- python-ideas@python

[Python-ideas] timedelta.strptime() and timedelta.strftime()

2023-02-02 Thread Thomas Mc Kay
I was looking for a simple intuitive way to parse a timedelta from a string. The best I could find feels clunky at best: https://stackoverflow.com/questions/4628122/ Solution 1 looks like this: ``` from datetime import datetime, timedelta t = datetime.strptime('05:20:25', '%H:%M:%S') delta = tim