anything like C++ references?
Erik Max Francis
max at alcyone.com
Sun Jul 13 22:42:23 CEST 2003
David McNab wrote:
> In Python, basic types like strings and numbers are a weird exception to
> the 'everything is an object' rule.
> When you pass any other object in a function, the function gets a ref to
> that object.
> But when you pass a string or numeric object, the whole thing (not a ref)
> gets passed.
This is completely incorrect. On the contrary, builtin types are
handled exactly uniformly in Python. The only difference here is that
the builtin types that you've listed, along with some others, are
immutable, so you cannot change them if you have a reference to them.
Contrast this to, say, Java, where there really is a solid distinction
between builtin fundamental types, like int and long, and actual object
types, derived from java.lang.Object, which are all passed by reference.
Python doesn't make this distinction.
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ But who shall dwell in these worlds if they be inhabited?
\__/ Johannes Kepler
More information about the Python-list