[Tutor] Error while using calendar module in Python 2.7

ranjan das ranjand2005 at gmail.com
Sat Mar 5 08:13:06 CET 2011

I ran the following code in python 2.6 and then in python 2.7 (using
calendar module) to manipulate dates and times

The following code works fine in Python 2.6 but throws up an error in Python
2.7. Can anyone please say why?


import datetime
import calendar

while monday.weekday() != calendar.MONDAY:

    monday -= oneday

oneweek = datetime.timedelta(days=7)

nextweek = today + oneweek

print next week

Traceback (most recent call last):
  File "C:\Python27\Foursoft\calendar.py", line 33, in <module>
    while friday.weekday() != calendar.FRIDAY:
AttributeError: 'module' object has no attribute 'FRIDAY'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110305/342f3b83/attachment.html>

More information about the Tutor mailing list