Sorry David
The correctly indented code with the while loop is
while friday.weekday() != calendar.MONDAY:
MONDAY -= oneday
oneweek = datetime.timedelta(days=7)
nextweek = today + oneweek
nextyear = today.replace(year=today.year+1)
print "Today (year-month-day) =", today
print "Most recent Monday =", monday
Is there any change in the calendar module from Python 2.6 to 2.7.
This example works fine in Python 2.6 but throws up an error in 2.7
On Sat, Mar 5, 2011 at 12:58 PM, David Hutto <[email protected]> wrote:
> Could you paste the whle code, because I get:
>
> >>> import datetime
> >>> import calendar
> >>>
> >>>
> >>>
> >>> while monday.weekday() != calendar.MONDAY:
> ...
> File "<stdin>", line 2
>
> ^
> IndentationError: expected an indented block
> >>> monday -= oneday
> File "<stdin>", line 1
> monday -= oneday
> ^
> IndentationError: unexpected indent
> >>>
> >>> oneweek = datetime.timedelta(days=7)
> >>>
> >>> nextweek = today + oneweek
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'today' is not defined
> >>>
> >>> print next week
>
--
The inherent vice of capitalism is the unequal sharing of blessings; the
inherent virtue of socialism is the equal sharing of miseries.
~ Winston Churchill
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor