On Sun, 22 Feb 2009 16:13:02 +0100, Torsten Mohr wrote: > Hi, > > 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?
Never, and never. > Integers are obviously passed by value, lists and dicts by reference. Your error is assuming that pass-by-value and pass-by-reference are the only two possibilities, consequently you are misinterpreting what you see. Python uses the same evaluation strategy regardless of the type of object being passed. Sometimes that strategy looks something like pass-by-value, and sometimes it looks something like pass-by-reference, but in fact it always behaves consistently no matter what object you use. > Is there a general rule? Some common formulation? http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing http://effbot.org/zone/call-by-object.htm -- Steven -- http://mail.python.org/mailman/listinfo/python-list