Skip to content

calendar.day_name returns a class object and not array #123445

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

Closed
sspTest opened this issue Aug 28, 2024 · 5 comments
Closed

calendar.day_name returns a class object and not array #123445

sspTest opened this issue Aug 28, 2024 · 5 comments
Labels
docs Documentation in the Doc dir

Comments

@sspTest
Copy link

sspTest commented Aug 28, 2024

Documentation

In the https://docs.python.org/3/library/calendar.html#calendar.day_name, its mentioned day_name returns "An array that represents the days of the week in the current locale." but it returns a class object. Also, it would be helpful to provide documentation with regards to how to use the object returned to obtain the day names.

Linked PRs

@sspTest sspTest added the docs Documentation in the Doc dir label Aug 28, 2024
@m4t5
Copy link
Contributor

m4t5 commented Aug 28, 2024

Confirmed

Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import calendar
>>> calendar.day_name
<calendar._localized_day object at 0x7fd3b687a020>

>>> [x for x in calendar.day_name]
['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

@hugovk
Copy link
Member

hugovk commented Aug 29, 2024

Would you like to create a PR to correct the text and add an example?

@serhiy-storchaka
Copy link
Member

day_name was a list, but then it was changed to a custom sequence in bpo-401842 (gh-33318).

We just need to change "array" to "sequence". The same for day_abbr, month_name and month_abbr.

We can also add more human readable repr for these sequences. But this is only for a new version.

@ericvsmith
Copy link
Member

I agree with @serhiy-storchaka that there's no need to be more specific than "sequence". I don't see the need to be more specific here and constrain any future changes.

@m4t5
Copy link
Contributor

m4t5 commented Aug 29, 2024

I made a PR at #123483

m4t5 added a commit to m4t5/cpython that referenced this issue Aug 30, 2024
m4t5 added a commit to m4t5/cpython that referenced this issue Aug 30, 2024
AA-Turner added a commit that referenced this issue Sep 25, 2024
#123483)

Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Eric V. Smith <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 25, 2024
…ributes (pythonGH-123483)

(cherry picked from commit 8447c93)

Co-authored-by: Mat S <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Eric V. Smith <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 25, 2024
…ributes (pythonGH-123483)

(cherry picked from commit 8447c93)

Co-authored-by: Mat S <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Eric V. Smith <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
AA-Turner added a commit that referenced this issue Sep 25, 2024
…tributes (GH-123483) (#124501)

gh-123445: calendar: Improve descriptions for day and month attributes (GH-123483)
(cherry picked from commit 8447c93)

Co-authored-by: Mat S <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Eric V. Smith <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
Yhg1s pushed a commit that referenced this issue Sep 26, 2024
…tributes (GH-123483) (#124500)

gh-123445: calendar: Improve descriptions for day and month attributes (GH-123483)
(cherry picked from commit 8447c93)

Co-authored-by: Mat S <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Eric V. Smith <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
Archived in project
Development

No branches or pull requests

6 participants