[Tutor] (no subject)

wilson edgar pinto babyboy@oninet.pt
Thu, 9 Nov 2000 02:32:09 -0000


This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C049F5.429EEA60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


hiya
hi i'm having a bit of a trouble understanding this error message, =
because i can't what's wrong in the code. this transposes almost all the =
code, and i get an error on the first print command (in bold) it =
"Invalid syntax, how come???, and since is correctly indented and in =
some previous version the same thing worked perfectly, i don't quite get =
why it doesn't work now.
oh this is was taken from a tutorial about using python in dynamic pages =
with apache.
help is welcomed
thankx in advance
wilson edgar

#!/python20/python
# calendin2.py - calend=E1rio dinamico - vers=E3o 2

print 'Content-type: text/html\n'

try:
    from time import time, localtime
    from calendar import monthcalendar
    from string import join

    ano, mes, hoje =3D localtime(localtime(time())[:3]

    print '<HTML><TITLE>Calend=E1rio dinamico</TITLE>'
    print '<BODY>'
    print '<CENTER>'
    print '<H1>Calend=E1rio de %s/%s</H1>' % (ano,mes)
    print '<TABLE>'
    print '<TR>'
    for dia_sem in ['seg','ter','qua','qui','sex','sab','dom']:
        if dia_sem in ['sab','dom']: bgcolor =3D 'green'
        else: bgcolor =3D 'blue'
        print '<th width=3D"45" BGCOLOR=3D"%s">'% bgcolor
        print '<H3>%s</H3></TH>' % dia_sem
    print '</TR>'
    for semana in monthcalendar(ano,mes):
        print'<TR>'
        num_dia_sem =3D 0
        for dia in semana:
            if dia =3D=3D hoje:
                bgclor=3D 'pink'
            elif num_dia_sem >=3D 5:
                bgcolor =3D 'ligthgreen'
            else:
                bgcolor =3D 'ligthblue'
            print '<td align=3D"rigth" bgcolor=3D"%s">' % bgcolor
            if dia !=3D 0:
                print '0<H2>%2d</H2>' % dia
            print '</TD>'
            num_dia_sem =3D num_ida_sem + 1
        print '</TR>'
    print '</TABLE></CENTER>'

except:
    import sys
    from traceback import print_exc
    sys.stderr =3D sys.stdout
    print '<HR><H3>Erro no CGI:</H3><PRE>'
    print_exc()
    print '</PRE>'
           =20



------=_NextPart_000_000D_01C049F5.429EEA60
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>hiya<BR>hi i'm having a bit of a =
trouble=20
understanding this error message, because i can't what's wrong in the =
code. this=20
transposes almost all the code, and i get an error on the first print =
command=20
(in bold) it "Invalid syntax, how come???,&nbsp;and since is correctly =
indented=20
and in some previous version the same thing worked perfectly, i don't =
quite get=20
why it doesn't work now.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>oh this is was taken from a tutorial =
about using=20
python in dynamic pages with apache.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>help is welcomed</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>thankx in advance</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>wilson edgar</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#!/python20/python<BR># calendin2.py - =
calend=E1rio=20
dinamico - vers=E3o 2</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>print 'Content-type: =
text/html\n'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>try:<BR>&nbsp;&nbsp;&nbsp; from time =
import time,=20
localtime<BR>&nbsp;&nbsp;&nbsp; from calendar import=20
monthcalendar<BR>&nbsp;&nbsp;&nbsp; from string import join</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; ano, mes, hoje =3D=20
localtime(localtime(time())[:3]</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; <FONT =
size=3D3><STRONG>print=20
'&lt;HTML&gt;&lt;TITLE&gt;Calend=E1rio=20
dinamico&lt;/TITLE&gt;'</STRONG></FONT><BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;BODY&gt;'<BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;CENTER&gt;'<BR>&nbsp;&nbsp;&nbsp; print '&lt;H1&gt;Calend=E1rio de=20
%s/%s&lt;/H1&gt;' % (ano,mes)<BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;TABLE&gt;'<BR>&nbsp;&nbsp;&nbsp; print =
'&lt;TR&gt;'<BR>&nbsp;&nbsp;&nbsp;=20
for dia_sem in=20
['seg','ter','qua','qui','sex','sab','dom']:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;=20
if dia_sem in ['sab','dom']: bgcolor =3D=20
'green'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else: bgcolor =3D=20
'blue'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print '&lt;th =
width=3D"45"=20
BGCOLOR=3D"%s"&gt;'% =
bgcolor<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'&lt;H3&gt;%s&lt;/H3&gt;&lt;/TH&gt;' % dia_sem<BR>&nbsp;&nbsp;&nbsp; =
print=20
'&lt;/TR&gt;'<BR>&nbsp;&nbsp;&nbsp; for semana in=20
monthcalendar(ano,mes):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
print'&lt;TR&gt;'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
num_dia_sem =3D=20
0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for dia in=20
semana:<BR>&nb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/TD&gt;'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
num_dia_sem =3D num_ida_sem + =
1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
print '&lt;/TR&gt;'<BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;/TABLE&gt;&lt;/CENTER&gt;'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>except:<BR>&nbsp;&nbsp;&nbsp; import=20
sys<BR>&nbsp;&nbsp;&nbsp; from traceback import =
print_exc<BR>&nbsp;&nbsp;&nbsp;=20
sys.stderr =3D sys.stdout<BR>&nbsp;&nbsp;&nbsp; print =
'&lt;HR&gt;&lt;H3&gt;Erro no=20
CGI:&lt;/H3&gt;&lt;PRE&gt;'<BR>&nbsp;&nbsp;&nbsp;=20
print_exc()<BR>&nbsp;&nbsp;&nbsp; print=20
'&lt;/PRE&gt;'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_000D_01C049F5.429EEA60--