On this page
calendar.isleap
Prev: calendar.IllegalWeekdayError | Up: calendar | Next: calendar.leapdays
Rel: calendar.calendar, calendar.Calendar, calendar.Day, calendar.firstweekday
Ref: docs.python.org — calendar.isleap
Tags: #public #python3 #stdlib #calendar
Import
import calendar
from calendar import isleap
Signature & Overview
calendar.isleap(year)
Return True for leap years, False for non-leap years.
Usage
import calendar
assert calendar.isleap(2024) is True
assert calendar.isleap(1900) is False
assert calendar.isleap(2000) is True
Gotchas
- Implements full Gregorian leap-year rules (divisible by 4, except centuries unless divisible by 400).
REPL Inspect
from calendar import isleap
help(isleap)
Linked from
Related notes
- tuts/python3/stdlib_module/calendar/IllegalWeekdayError Linked here; links to this page; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/leapdays Linked here; links to this page; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/calendar Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/Calendar_class Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/Day Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/firstweekday Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/calendar/HTMLCalendar shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/IllegalMonthError shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/LocaleHTMLCalendar shared tags: #calendar, #stdlib