[Tutor] Pass by reference
Praveen Pathiyil
ppathiyi@cisco.com
Wed, 11 Jul 2001 19:44:24 +0530
This is a multi-part message in MIME format.
------=_NextPart_000_0455_01C10A41.E3191B70
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
Can we do a "pass by reference" in python ?
Ex:
( I would like to know whether there is a way to have the modified =
ex_dict to be visible in modified form in func1 with out explicitly =
returning that )
def func2(x, ex_dict):
ex_dict[x] =3D x*x
def func1(a):
ex_dict =3D {}
func2(a, ex_dict)
func1(2)
TIA,
Praveen.
------=_NextPart_000_0455_01C10A41.E3191B70
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.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>Can we do a "pass by reference" in python ?</DIV>
<DIV> </DIV>
<DIV>Ex:</DIV>
<DIV> </DIV>
<DIV>( I would like to know whether there is a way to have the modified =
ex_dict=20
to be visible in modified form in func1 with out explicitly returning =
that=20
)</DIV>
<DIV> </DIV>
<DIV>def func2(x, ex_dict):</DIV>
<DIV> ex_dict[x] =3D x*x</DIV>
<DIV> </DIV>
<DIV>def func1(a):</DIV>
<DIV> ex_dict =3D {}</DIV>
<DIV> func2(a, ex_dict)</DIV>
<DIV> </DIV>
<DIV>func1(2)</DIV>
<DIV> </DIV>
<DIV>TIA,</DIV>
<DIV>Praveen.</DIV></BODY></HTML>
------=_NextPart_000_0455_01C10A41.E3191B70--