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

Ernst Noch enoch at gmx.net
Fri Jan 6 04:13:37 EST 2006


Mike Meyer wrote:
> 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.


Maybe next time showing something like the following trivial snippet 
might help demonstrate that the core of the matter doesn't is not the 
way python treats parameters?

>>> def func(param, what):
	if what:
		param['foo'] = 'changed'
	else:
		temp = param['foo'] # temp is _not_ a reference!
		temp = 'changed'




More information about the Python-list mailing list