About PEP 303, I use divmod for lots (and lots) of things, but I've got no real use for an extended divmod() either. -1: it would be low-use, confusing clutter. [Barry] > Interesting. Just yesterday I wrote a simple stopwatch-like timer > script and I found that I needed three divmod calls to convert from > seconds into a datetime.time object. You don't need any divmods for that ... ... > Actually, no, because datetime.time(seconds=50227) throws an exception. That's right: the time class models a time of day, not "seconds from Barry's implied midnight epoch" (or something like that). What you wanted was a timedelta instead. Converting that to a time is then simplicity itself <wink>: >>> print (datetime(1, 1, 1) + timedelta(seconds=50227)).time() 13:57:07 You have to go thru a datetime object first because time objects don't support arithmetic either. That isn't all bad. By going thru a datetime first, it's clear what happens if the number of seconds you feed in exceeds a day's worth. You can check for that or ignore it then, depending on what your app wants (it may or may not be "an error", depending on the app).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4