Hello all,
This is all good explanation, but could use a bit of tweaking. Where the
pointer analogy with C breaks down is that C pointers require explicit
dereferencing. In this regard, the Python model is actually closer to C
++ reference variables, which are automatically dereferenced. Of course
Martelli's response. ;-)
-- Forwarded message --
From: Alex Martelli <[EMAIL PROTECTED]>
Date: Sun, May 4, 2008 at 2:36 PM
Subject: Re: [Edu-sig] How does Python do Pointers?
To: Anna Ravenscroft <[EMAIL PROTECTED]>
Cc: edu-sig@python.org
With thanks to Anna for forwarding this.
Hi Dave,
For students familiar with C, the most straightforward analogy is
that ALL of Python's names are akin to C's pointers. This is
certainly the closest match of the three C/C++ models (value,
pointer, reference).
Even for new programmers with no previous knowledge, we make sure
This was the question from a student at my recent lecture to a class of
engineering students studying C. My answer was brief: It doesn't - arguments
are passed by value. Then I thought, this is really misleading for students of
C, where pass-by-value means making a copy of the passed object.