How to Teach Python "Variables"

Chris Mellon arkanes at gmail.com
Tue Nov 27 11:52:14 EST 2007


On Nov 27, 2007 10:25 AM, Aaron Watters <aaron.watters at gmail.com> wrote:
> On Nov 27, 10:06 am, hdante <hda... at gmail.com> wrote:
> > On Nov 25, 5:31 pm, none <""atavory\"@(none)"> wrote:
> ....
> >  And that's it. I think that there is confusion because everything we
> > do with python variables are pointer dereferences, except for the
> > attribution, that instead of dereferencing and operating the object,
> > just changes the pointer. The scope is just a matter of using
> > automatic memory management or not.
>
> I hope the participants in this thread realize
> that this sort of discussion will cause
> any programming newbie to immediately melt into the
> floor.
>

Well, this (part of) the conversation was specifically about using the
knowledge that a C programmer already has and how best to teach them
how Python "variables" work in that context. I think that even the
people who disagree with my position would agree that, if your goal
were to teach a new student about Python variables, teaching them C
pointers first would be a really terrible way to go about it.

> I would try to avoid talking
> in generalities about python variables versus C or
> lisp or whatever, unless I was teaching an upper division
> college programming languages survey class.
>

I disagree, although it's not really on topic for the thread. There's
no reason why low level details need to be relegated to "upper
division" college classes. It shouldn't be in Programming Languages
101, but it's something that I would expect a first year student who's
planning to pursue a programming career or a comp sci degree to be
exposed to. It's not out of place even in high school - that's where I
first learned C.

> Instead, I'd fire up the interactive interpreter and
> illustrate how things work via examples, avoiding the
> weird cases at all costs.  If they ask about the
> relationship to C or java or whatever
> I would encourage them to not worry about it,
> and only go deeper if pressed.
>
> BTW, at the moment I'm "facilitating" an online
> C# class for fun and a very little profit in my
> spare time.  I'm becoming quite convinced that
> especially the beginning programmers would have far
> less difficulty with Python, largely because
> there is less syntactic noise to confuse them and
> because they can fiddle around with everything
> up to and including advanced concepts using simple
> examples at the interactive prompt.
>

The idea of boxes with names is generally far more intuitive to
absolute beginners than pointers, if only because you have to
understand more of the underlying implementation to make use of
pointers. There's other (very good) reasons to use Python as a first
language for beginners, too.


> But if you talk like the above to them, they
> will run for the hills... (no offense intended).
>
>   -- Aaron Watters
>



More information about the Python-list mailing list