Skip to content

gh-108202: Document calendar.Calendar.firstweekday #128566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Doc/library/calendar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,33 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
itself. This is the job of subclasses.


:class:`Calendar` instances have the following methods:
:class:`Calendar` instances have the following methods and attributes:

.. attribute:: firstweekday

The first weekday as an integer (0--6).

This property can also be set and read using
:meth:`~Calendar.setfirstweekday` and
:meth:`~Calendar.getfirstweekday` respectively.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth recommending usage of either the attribute or the methods, per the zen:

There should be one-- and preferably only one --obvious way to do it.

If you want though, I'm fine to leave it as is. I'm just being nitpicky :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that, but I think the zen train already left the calendar module API :) IMO, a better approach would be to soft deprecate the set/get method pair.


.. method:: getfirstweekday()

Return an :class:`int` for the current first weekday (0-6).
Return an :class:`int` for the current first weekday (0--6).

Identical to reading the :attr:`~Calendar.firstweekday` property.

.. method:: setfirstweekday(firstweekday)

Set the first weekday to *firstweekday*, passed as an :class:`int` where Monday is 0 and Sunday is 6.
Set the first weekday to *firstweekday*, passed as an :class:`int` (0--6)

Identical to setting the :attr:`~Calendar.firstweekday` property.

.. method:: iterweekdays()

Return an iterator for the week day numbers that will be used for one
week. The first value from the iterator will be the same as the value of
the :attr:`firstweekday` property.
the :attr:`~Calendar.firstweekday` property.


.. method:: itermonthdates(year, month)
Expand Down
Loading