How to Teach Python "Variables"

hdante hdante at
Tue Nov 27 20:12:12 CET 2007

On Nov 27, 2:25 pm, Aaron Watters <aaron.watt... at> wrote:
> I hope the participants in this thread realize
> that this sort of discussion will cause
> any programming newbie to immediately melt into the
> floor.

 All right, answering the original question is good. :-P

 1) If the students can't program and you have chosen to teach them by
using python, then they don't have any "assignment == copy" hard-coded
in their minds. Just teach them that python assignments are like
creating aliases, or "mirrors". That is,

  a = 2

 Makes "a" an alias of 2.

  l = [1, 2, 3]

 Makes l[0] an alias of 1

 Don't ever speak the word copy in class.

 2) If the students come from different backgrounds, typically having
programmed in high level languages, like pascal, java, C#, etc, then
you may call python variables either aliases or references, but state
clearly that "assignment in python doesn't mean object copy, but
reference change".

 3) If you're teaching in college, always show the students the formal

>   -- Aaron Watters
> ===

More information about the Python-list mailing list