This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients belopolsky, jborgohain, lemburg, mark.dickinson, mwtoews, pitrou
Date 2010-05-21.19:58:03
SpamBayes Score 0.0044398815
Marked as misclassified No
Message-id <AANLkTilXguCd7NVAO0XROvhIMOQGzwU9ZMpmJN1FJnrd@mail.gmail.com>
In-reply-to <1274398033.3141.5.camel@localhost.localdomain>
Content
On Thu, May 20, 2010 at 7:27 PM, Antoine Pitrou <report@bugs.python.org> wrote:
>
>> .. The OP's premise was that
>> t.timetuple()[7] was unreadable, but in the modern python, the same
>> can be written as t.timetuple().tm_yday.
>
> Could I suggest such example be added to the documentation, though?

The documentation for timetuple method [1, 2] already contains a
recipe for computing yday which is more efficient than
t.timetuple().tm_yday:

 yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1

Maybe it can be improved by making it discoverable in searches for yday:

"""
... is equivalent to time.struct_time((d.year, d.month, d.day, d.hour,
d.minute, d.second, d.weekday(), yday, dst)), where yday =
d.toordinal() - date(d.year, 1, 1).toordinal() + 1 is the day number
of the year starting from 1 for January 1st.
"""

[1] http://docs.python.org/py3k/library/datetime.html#datetime.date.timetuple
[2] http://docs.python.org/py3k/library/datetime.html#datetime.datetime.timetuple
History
Date User Action Args
2010-05-21 19:58:06belopolskysetrecipients: + belopolsky, lemburg, mark.dickinson, pitrou, mwtoews, jborgohain
2010-05-21 19:58:04belopolskylinkissue1436346 messages
2010-05-21 19:58:03belopolskycreate