[Tutor] Why thus?
Arthur Siegel
ajs@ix.netcom.com
Sun, 12 Mar 2000 12:27:33 -0500
This is a multi-part message in MIME format.
------=_NextPart_000_0005_01BF8C1E.57711700
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Can't quite see what's happening here.
counter=3D0
class Count:
def __init__(self):
print counter
Count()
gets :
0
Process completed successfully
But:
counter=3D0
class Count:
def __init__(self):
counter=3Dcounter+1
print counter
Count()
gets:
Traceback (innermost last):
File "C:\temp\test.py", line 6, in ?
Count()
File "C:\temp\test.py", line 4, in __init__
counter=3Dcounter+1
NameError: counter
Process completed with exit code 1
------=_NextPart_000_0005_01BF8C1E.57711700
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 content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META=20
content=3D"commtouch, pronto, mail, free email, free, branded, web =
based, free web based email, communications, internet, software, =
advertising banners, e-mail, free software"=20
name=3Dkeywords>
<META content=3D"MSHTML 5.00.2919.6307" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Can't quite see what's happening here.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>counter=3D0<BR>class Count:<BR> def=20
__init__(self):<BR> print =
counter<BR>Count()</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>gets :</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>0</FONT></DIV>
<DIV><FONT size=3D2>Process completed successfully<BR></FONT></DIV>
<DIV><FONT size=3D2>But:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>counter=3D0<BR>class Count:<BR> def=20
__init__(self):<BR> counter=3Dcounter+1<BR> print=20
counter<BR>Count()<BR></FONT></DIV>
<DIV><FONT size=3D2>gets:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Traceback (innermost last):<BR> File =
"C:\temp\test.py",=20
line 6, in ?<BR> Count()<BR> File =
"C:\temp\test.py",=20
line 4, in __init__<BR> =
counter=3Dcounter+1<BR>NameError:=20
counter</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>Process completed with exit code=20
1<BR><BR></DIV></FONT></BODY></HTML>
------=_NextPart_000_0005_01BF8C1E.57711700--