Python provides neither pass-by-reference nor pass-by-value argument passing. Please read this for an explanation of why people sometimes think that it does, and what Python actually does instead:
http://import-that.dreamwidth.org/1130.html
To get an effect *similar* to pass-by-reference, you can wrap your variable in a list, and then only operate on the list item. For example:
one = [1]
two = [2]
def swap(a, b):
a[0], b[0] = b[0], a[0]
swap(one, two)
print one[0], two[0]
=> will print "2 1"
But note carefully that in the swap function I do not assign directly to the arguments a and b, only to their items a[0] and b[0]. If you assign directly to a and b, you change the local variables.
# This does not work.
def swap(a, b):
a, b = b, a
Rather than trying to fake pass-by-reference semantics, it is much better to understand Python's capabilities and learn how to use it to get the same effect. For example, instead of writing a swap procedure, it is much simpler to just do this:
one = 1
two = 2
one, two = two, one
print one, two
=> will print "2 1"