[Tutor] Error while using calendar module in Python 2.7
alan.gauld at btinternet.com
Sat Mar 5 10:44:51 CET 2011
"ranjan das" <ranjand2005 at gmail.com> wrote
> 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:
where does 'monday' come from?
Can you send a minimal example that could actually run that shjows the
This is obviously just a code fragment.
> 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'
The obvious solution is that calendar has changed between 2.6 and 2.7
but looking on v3.1(I don;t have 2.7 installed) it looks the same
Certainly the day constants are still there.
Author of the Learn to Program web site
More information about the Tutor