[issue5788] datetime.timedelta is inconvenient to use...
Mark Dickinson dicki...@gmail.com added the comment: What about def total_minutes(td): return td / datetime.timedelta(minutes=1) ? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Brian Quinlan br...@sweetapp.com added the comment: You'll probably get more traction if you file a new bug. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Giampaolo Rodola' g.rod...@gmail.com added the comment: Sorry for commenting on a closed issue but I just bumped into a problem requiring a total_minute() method I ended up implementing by doing some raw math by hand. Would it be a reasonable addition? If so I'll open a separate issue. -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Mark Dickinson dicki...@gmail.com added the comment: A late note: this would be redundant if the oft-requested division of timedeltas were implemented: t.total_seconds could then be spelt t/timedelta(seconds=1) with the advantage that there would then be a natural way to spell t.total_days or t.total_hours as well. -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Mark Dickinson dicki...@gmail.com added the comment: That should be t.total_seconds(), of course. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Antoine Pitrou pit...@free.fr added the comment: A late note: this would be redundant if the oft-requested division of timedeltas were implemented: t.total_seconds could then be spelt t/timedelta(seconds=1) It would be less obvious, though. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Antoine Pitrou pit...@free.fr added the comment: The patch is committed in r76529 (trunk) and r76530 (py3k). Thank you! -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +mw44118 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Antoine Pitrou pit...@free.fr added the comment: Given the timing, I fear this will have to wait for 3.2. -- versions: +Python 3.2 -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Changes by Brian Quinlan br...@sweetapp.com: Added file: http://bugs.python.org/file13721/totalseconds2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Brian Quinlan br...@sweetapp.com added the comment: Attached is a patch that implements .total_seconds as an instance method -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
New submission from Brian Quinlan br...@sweetapp.com: ...in seconds-based library functions (e.g. time.sleep) and calculations (e.g. distance = velocity * ?). -- components: Library (Lib) messages: 86132 nosy: bquinlan severity: normal status: open title: datetime.timedelta is inconvenient to use... versions: Python 3.0, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Changes by Brian Quinlan br...@sweetapp.com: -- keywords: +patch Added file: http://bugs.python.org/file13719/totalseconds.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Georg Brandl ge...@python.org added the comment: Please include a proper description of your problem, and a patch description when you post a patch. -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Brian Quinlan br...@sweetapp.com added the comment: I did add a patch description: Adds a datetime.total_seconds attribute - is that unclear? The idea is that you should be able to extract the total number of seconds in the duration i.e. dt = datetime.timedelta(seconds=1234567.89) dt.total_seconds 1234567.89 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Georg Brandl ge...@python.org added the comment: I saw the patch description as well, but usually you put that description, and perhaps a motivation as well, in the comment. That way it's easier for people to directly see what an issue is about. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Brian Quinlan br...@sweetapp.com added the comment: OK, a bit on motivation: 1. datetime.timedelta instances are a convenient way of representing durations 2. datetime.timedelta instances cannot be conveniently used in many calculations e.g. calculating distance based on velocity and time 3. datetime.timedelta instances cannot be conveniently used in many library functions e.g. time.sleep(), urllib2.urlopen(timeout=) I propose to fix that by adding a timedelta.total_seconds attribute that equals: timedelta.days * 3600 * 24 + timedelta.seconds + timedelta.microseconds / 10.0 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Antoine Pitrou pit...@free.fr added the comment: The addition looks quite legitimate to me. The only thing is that it may be better as a method (total_seconds()) rather than an attribute, given the other APIs in the datetime module. Also, the patch lacks some unit tests. -- nosy: +pitrou versions: +Python 2.7 -Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Changes by Antoine Pitrou pit...@free.fr: -- priority: - normal stage: - patch review type: - feature request ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5788] datetime.timedelta is inconvenient to use...
Antoine Pitrou pit...@free.fr added the comment: Sorry for the last comment about unit tests, they are here actually :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com