How to Teach Python "Variables"

hdante hdante at gmail.com
Tue Nov 27 14:12:12 EST 2007


On Nov 27, 2:25 pm, Aaron Watters <aaron.watt... at gmail.com> 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
definition.

>
>
>   -- Aaron Watters
>
> ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=evil+fish




More information about the Python-list mailing list