Reference or Value?
lists at cheimes.de
Sun Feb 22 16:23:58 CET 2009
Torsten Mohr schrieb:
> how is the rule in Python, if i pass objects to a function, when is this
> done by reference and when is it by value?
> def f1(a):
> a = 7
> b = 3
> print b
> => 3
> Integers are obviously passed by value, lists and dicts by reference.
> Is there a general rule? Some common formulation?
Python uses neither call by reference nor call by value. It's called
call by sharing or call by object. http://effbot.org/zone/call-by-object.htm
More information about the Python-list