[Tutor] functions

david din22@cox.net
Sun Dec 1 08:57:03 2002


This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C2990F.0480BC20
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

why does this work:
>>> d=3D{}
>>> d
{}
>>> def myfun():
 d[0]=3D'hello'

=20
>>> myfun()
>>> d
{0: 'hello'}

but this doesnt?

>>> d=3D'hello'
>>> d
'hello'
>>> def myfun():
 d=3D'goodbye'

=20
>>> myfun()
>>> d
'hello'
>>>
=20

------=_NextPart_000_0005_01C2990F.0480BC20
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 content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>why does this work:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; d=3D{}<BR>&gt;&gt;&gt;=20
d<BR>{}<BR>&gt;&gt;&gt; def =
myfun():<BR>&nbsp;d[0]=3D'hello'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;<BR>&gt;&gt;&gt; =
myfun()<BR>&gt;&gt;&gt;=20
d<BR>{0: 'hello'}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>but this doesnt?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; =
d=3D'hello'<BR>&gt;&gt;&gt;=20
d<BR>'hello'<BR>&gt;&gt;&gt; def =
myfun():<BR>&nbsp;d=3D'goodbye'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;<BR>&gt;&gt;&gt; =
myfun()<BR>&gt;&gt;&gt;=20
d<BR>'hello'<BR>&gt;&gt;&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</FONT></DIV></BODY></HTML>

------=_NextPart_000_0005_01C2990F.0480BC20--