Passing by value instead of reference
Janko Hauser
jhauser at ifm.uni-kiel.de
Wed May 10 13:12:14 EDT 2000
Frederic says no :-)
But in case of mutable arguments one can use sometimes (if one knows
the type of the arguments beforehand) copy.copy() or copy.deepcopy(),
or not?
import copy
def byvalue(a):
a=copy.deepcopy(a)
a[3]=10
a=[1,2,3,4]
print a
byvalue(a)
print a
This is not general, but helps in some situations.
HTH,
__Janko
--
Institut fuer Meereskunde phone: 49-431-597 3989
Dept. Theoretical Oceanography fax : 49-431-565876
Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de
24105 Kiel, Germany
More information about the Python-list
mailing list