New submission from Paul Ganssle <p.gans...@gmail.com>:
In a recent python-dev thread, there was some confusion about how to get something like `timedelta.total_microseconds()`. There is already an existing, supported idiom for this, which is that `timedelta` implements division: td = timedelta(hours=1) num_microseconds = td / timedelta(microseconds=1) In this e-mail ( https://mail.python.org/pipermail/python-dev/2019-February/156351.html ), Nick Coghlan proposed that we update the documentation and there were no objections, quoting: * In the "Supported Operations" section of https://docs.python.org/3/library/datetime.html#timedelta-objects, change "Division (3) of t2 by t3." to "Division (3) of overall duration t2 by interval unit t3." * In the total_seconds() documentation, add a sentence "For interval units other than seconds, use the division form directly (e.g. `td / timedelta(microseconds=1)`)" I am starting this issue to track that change. ---------- assignee: docs@python components: Documentation, Library (Lib) messages: 336765 nosy: belopolsky, docs@python, ncoghlan, p-ganssle priority: normal severity: normal status: open title: Improve documentation about converting datetime.timedelta to scalars versions: Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36138> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com