Sorry David<br><br>The correctly indented code with the while loop is <br><br><br>while friday.weekday() != calendar.MONDAY:<br> MONDAY -= oneday<br><br>oneweek = datetime.timedelta(days=7)<br><br>nextweek = today + oneweek<br>
<br>nextyear = today.replace(year=today.year+1)<br><br>print "Today (year-month-day) =", today<br> <br>print "Most recent Monday =", monday<br><br><br><br><br>Is there any change in the calendar module from Python 2.6 to 2.7.<br>
<br>This example works fine in Python 2.6 but throws up an error in 2.7<br><br><br><div class="gmail_quote">On Sat, Mar 5, 2011 at 12:58 PM, David Hutto <span dir="ltr"><<a href="mailto:smokefloat@gmail.com">smokefloat@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Could you paste the whle code, because I get:<br>
<div class="im"><br>
>>> import datetime<br>
>>> import calendar<br>
>>><br>
>>><br>
>>><br>
>>> while monday.weekday() != calendar.MONDAY:<br>
</div>...<br>
File "<stdin>", line 2<br>
<br>
^<br>
IndentationError: expected an indented block<br>
>>> monday -= oneday<br>
File "<stdin>", line 1<br>
monday -= oneday<br>
^<br>
IndentationError: unexpected indent<br>
<div class="im">>>><br>
>>> oneweek = datetime.timedelta(days=7)<br>
>>><br>
>>> nextweek = today + oneweek<br>
</div><div class="im">Traceback (most recent call last):<br>
</div> File "<stdin>", line 1, in <module><br>
NameError: name 'today' is not defined<br>
>>><br>
>>> print next week<br>
</blockquote></div><br><br clear="all"><br>-- <br>The inherent vice of capitalism is the unequal sharing of blessings; the inherent virtue of socialism is the equal sharing of miseries. <br><br>~ Winston Churchill<br>