Experiences/guidance on teaching Python as a first programming language

Chris Angelico rosuav at gmail.com
Wed Dec 11 11:45:51 EST 2013


On Thu, Dec 12, 2013 at 3:27 AM, rusi <rustompmody at gmail.com> wrote:
> However when we have an REPL language like python, one has the choice
> of teaching the hello-world program as:
>
> print ("Hello World")
>
> or just
>
> "Hello World"
>
> The second needs one more assumption than the first, viz that we are in the
> REPL, however on the whole it creates better habits in the kids.

How is the bare string creating better habits? The only time I've ever
been happy with bare strings having functionality[1] is in shell-like
languages (including REXX; the one time I built a REXX system in which
bare strings weren't executed as commands was a MUD, where command
handlers could use bare strings to send lines of text to the client,
and I wasn't happy with that - an explicit function would have been
better). I'd much rather teach a function that produces clean output
than depend on the REPL for Hello World. Now, depending on the REPL
for *expressions* is quite another thing.

>>> 1+2
3

That makes perfect sense! But it's using Python as a calculator, not
as a programming language. Python blurs the line a bit, but for
teaching programming, I'd use programming style even at the REPL:

>>> print("Hello, world!")
Hello, world!

ChrisA

[1] I don't have anything to footnote here, I just felt like having one.



More information about the Python-list mailing list