Pass by reference ?

Michael Hudson mwh21 at cam.ac.uk
Wed Apr 5 12:16:12 EDT 2000


Jacek Generowicz <jmg at ecs.soton.ac.uk> writes:

> Michael Hudson wrote:
> 
> > Python never ever copies anything when you pass it as an argument to a
> > function - it's just that sometimes the things you pass are immutable
> > - which is when it looks like call by value - and sometimes they're
> > mutable - when it looks a bit like call by reference.
> 
> Not necessarily; consider the following (and please excuse my Python-naive
> coding style):

[snip]
 
> So whether the call resembles by-reference or by-value depends on what you do
> with the mutable object.

which is why I said:

> Try to cast Python semantics in terms of what other langauges do is
> confusing - I've just successfully confused myself trying (as you
> could see if you could read my kill-ring) - and is hence to be
> considered bogus, because Python's semantics are actually extremely
> straightforward.

but it still doesn't copy the argument.  The code you posted only
confuses if you have a flawed understanding of assignment in Python
(which is the same problem, of course, as the semantics of argument
passing and variable assigment are the same - for a very good reason).

getting-bored-of-thie-yet-everyone?-ly y'rs
M.

-- 
  ... but I guess there are some things that are so gross you just have
  to forget,  or it'll destroy something within you.  perl is the first
  such thing I have known.                 -- Erik Naggum, comp.lang.lisp



More information about the Python-list mailing list