"always passes by reference"
Justin Sheehy
dworkin at ccs.neu.edu
Wed Jul 26 13:35:13 EDT 2000
weeks at golden.dtc.hp.com ((Greg Weeks)) writes:
> def f(a):
> a = 42
>
> x = 1
> f(x)
> print x # PRINTS 1
You're not demonstrating calling convention here. You're demonstrating
assignment semantics.
If the end result of the above example was saying anything meaningful
about calling conventions in Python, then this would be hard to explain:
>>> def g(b):
... b[1] = 'whoops'
...
>>> y = [1, 2, 3]
>>> g(y)
>>> y
[1, 'whoops', 3]
-Justin
More information about the Python-list
mailing list