Is 'everything' a refrence or isn't it?

Mike Meyer mwm at mired.org
Thu Jan 5 20:47:44 EST 2006


Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:
> Thinking about Python's behaviour ("it always passes references to
> objects") will invoke misleading frames in many programmers' minds. The
> word "reference" is misleading and should be avoided, because what the
> average non-Python programmer understands by the word is different from
> what the experienced Pythonista understands by it.

Yes, but it's not misleading because "reference" doesn't mean what
they think it means. "reference" means the same thing in Python as it
does in C and similar languages. It's misleading because "variables"
and "assignment" in Python don't do the things they do in C. Some of
the places that this shows up is when you're dealing with call by
reference, or with references in a list.

> We know that this will happen because it has happened time and time again
> in the past. Are we incapable of learning from experience? Are we
> intelligent sentient beings or do we just parrot what was said in the
> past with no concern for the consequences of what we say?

No, we learned to say "binding" and "names". We also learned that
while giving newbies false information like "Python doesn't have
references" or "Python isn't call-by-reference" will help them get
past the immediate problem, it sets them up to be confused in some
other area where variables and assignments don't do what they
think. So we've learned to deal with the disease instead of the
symptoms, and tell them how variables in Python behave differently
from variables in C, or Pascal, or ALGOL, or FORTRAN, or whatever.

     <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list