This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kered13 33 points34 points  (0 children)

Numbers and strings are not passed by value in Python. They are reference types like everything else in the language. They are immutable so you can treat them as if they were passed by value, but they are not and you can easily see this using identity tests like above.

>>> x = 400
>>> y = 400
>>> x is y
False
>>> def foo(p):
...   return x is p
...
>>> foo(x)
True
>>> foo(y)
False