[Tutor] dictionaries
Cameron Stoner
wolf_binary@hotmail.com
Wed, 20 Feb 2002 21:38:02 -0600
This is a multi-part message in MIME format.
------=_NextPart_000_0005_01C1BA56.DFD952C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I would like to know why the C part of my dictionary when I update it =
from the 2nd one goes before B.
>>> x =3D "A"
>>> y =3D "1"
>>> dict=3D{}
>>> dict2 =3D {x:y}
>>> dict.update(dict2)
>>> dict
{'A': '1'}
>>> x =3D "B"
>>> y =3D "2"
>>> dict2 =3D {x:y}
>>> dict.update(dict2)
>>> dict
{'A': '1', 'B': '2'}
>>> x =3D "C"
>>> y =3D "3"
>>> dict2 =3D {x:y}
>>> dict.update(dict2)
>>> dict
{'A': '1', 'C': '3', 'B': '2'}
Thanks,
Cameron Stoner=20
>>>=20
------=_NextPart_000_0005_01C1BA56.DFD952C0
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 6.00.2713.1100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I would like to know why the C part of =
my=20
dictionary when I update it from the 2nd one goes before B.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>>>> x =3D "A"<BR>>>> =
y =3D=20
"1"<BR>>>> dict=3D{}<BR>>>> dict2 =3D =
{x:y}<BR>>>>=20
dict.update(dict2)<BR>>>> dict<BR>{'A': '1'}<BR>>>> x =
=3D=20
"B"<BR>>>> y =3D "2"<BR>>>> dict2 =3D =
{x:y}<BR>>>>=20
dict.update(dict2)<BR>>>> dict<BR>{'A': '1', 'B': =
'2'}<BR>>>>=20
x =3D "C"<BR>>>> y =3D "3"<BR>>>> dict2 =3D =
{x:y}<BR>>>>=20
dict.update(dict2)<BR>>>> dict<BR>{'A': '1', <STRONG>'C': =
'3'</STRONG>,=20
'B': '2'}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Cameron Stoner </DIV>
<DIV><BR>>>> </FONT></DIV></BODY></HTML>
------=_NextPart_000_0005_01C1BA56.DFD952C0--