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.

classification
Title: calendar module .isleap() probleam
Type: Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Dyl Tuckey, abarry
Priority: normal Keywords:

Created on 2016-06-24 14:52 by Dyl Tuckey, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg269183 - (view) Author: Dyl Tuckey (Dyl Tuckey) Date: 2016-06-24 14:52
I don't know why but whenever I try and run this code:
import calendar
import time
calendar = calendar.month(2016,6)
print ("Loading date, time, month and leap year status")
time.sleep(5)
print (calendar)
localtime = time.asctime(time.localtime(time.time()))
print (localtime)
if calendar.isleap(2016) == True:
    print("This year is a leap year")
else:
    print("This year is not a leap year")


It come up with:
Loading date, time, month and leap year status
     June 2016
Mo Tu We Th Fr Sa Su
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

Fri Jun 24 15:46:12 2016
Traceback (most recent call last):
  File "C:\Users\Dylan\Desktop\Python\Calendar.py", line 9, in <module>
    if calendar.isleap(2016) == True:
AttributeError: 'str' object has no attribute 'isleap'

And I don't know why I keep getting error messages
msg269184 - (view) Author: Anilyka Barry (abarry) * (Python triager) Date: 2016-06-24 14:56
You're overriding the 'calendar' variable, holding the module, by the result of your 'calender.month' call, which happens to be a str. Use a different variable name (e.g. 'result') and the error will disappear.

Unrelated, but don't check for 'if x == True' - just do 'if x' and the result will be the same (also allows for any other result than booleans).
msg269191 - (view) Author: Dyl Tuckey (Dyl Tuckey) Date: 2016-06-24 16:40
Thank you ebarry. I would probably never have figured that out
History
Date User Action Args
2022-04-11 14:58:33adminsetgithub: 71569
2016-06-24 16:40:27Dyl Tuckeysetmessages: + msg269191
2016-06-24 14:56:31abarrysetstatus: open -> closed

type: compile error ->
components: - IDLE

nosy: + abarry
messages: + msg269184
resolution: not a bug
stage: resolved
2016-06-24 14:52:56Dyl Tuckeycreate