[Edu-sig] How does Python do Pointers?

Richard Enbody enbody at cse.msu.edu
Tue May 6 18:08:39 CEST 2008

This discussion has been interesting: we could really drive this 
discussion into the obscure by bringing in  'passing by name' where 
actual parameters remain unevaluated until the point of use.  :-)

I also agree that Michael's 'post-it-note' analogy is a good one for 

An interesting issue to consider is how to best set up students to 
understand pointers in subsequent languages.  The 'post-it-note' analogy 
seems to be a reasonable starting point.  If one understands naming from 
that standpoint, transitioning to pointers could be reasonable.  I 
believe we found that to be the case in our transition to a C++ based 
CS2 course, but I haven't examined the data carefully yet.

enbody at cse.msu.edu

David MacQuigg wrote:
> I agree, there is no reason to dig into call-by-??? terminology with new "untainted" programmers.  The sticky-note analogy is all we need for these students.  The figures in Michael's book are excellent.
> However, having been tainted by C, I am finding the discussion interesting.  I just don't understand why there is so much confusion with these call-by terms.  Does the function get a copy of the object or a reference to the original object?  It's got to be one or the other.
> At 10:11 PM 5/5/2008 -0500, Michael H.Goldwasser wrote:
>>  Python's model is quite clean, it just doesn't match up perfectly
>>  with the standard call-by-??? terminology.
> In call-by-reference evaluation, a function receives an implicit reference to the argument, rather than a copy of its value.
> -- http://en.wikipedia.org/wiki/Call_by_value
> By this definition, Python's model is call-by-reference, even though the reference (pointer) is not seen by the user.  C's model is call-by-value, even though that value can be an explicitly-evaluated address (pointer).
> -- Dave
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig

More information about the Edu-sig mailing list