[Tutor] Function Return Values (or References)
John Steedman
johnsteedman360 at gmail.com
Mon Jun 24 10:12:13 CEST 2013
Hi Tutors,
I'm confused by the following possible contradiction. Would someone please
explain or point me to the right docs.
FACT 1
"Variables in python hold references to objects."
http://en.wikipedia.org/wiki/Python_syntax_and_semantics
FACT 2
>>>def Increment ( x ) :
>>> // return x + 1
>>> x = x + 1
>>> return x
>>>
>>>y = 1
>>>z = Increment ( y )
>>>y
1
>>>z
2
By FACT 1 x should be a reference parameter...?
By Fact 2 x would seem to be a copy...?
What in the world of dynamic typing is going on?
Many thanks,
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130624/e9f9502f/attachment.html>
More information about the Tutor
mailing list