Begginers Guide - Exrcise. Help me, plz!

Sheila King usenet at thinkspot.net
Fri Mar 22 20:41:21 EST 2002


On Fri, 22 Mar 2002 10:38:22 -0800, Jeff Shannon <jeff at ccvcorp.com> wrote
in comp.lang.python in article <3C9B7A1E.451453BA at ccvcorp.com>:

> 
> 
> Jim Dennis wrote:
> 
> >  Shouldn't all these (helpful) examples be using raw_input() rather
> >  than input().  Do we really want the new user to be implicitly and
> >  blindly using eval(raw_input())?
> 
> Yes, they should.  :)  The calls to input() should, in this case, all be
> replaced by int(raw_input()), and optionally wrapped in a try/except and while
> loop, so that the program can prompt again if a non-numeric value is given.  I
> almost mentioned this in my earlier response, but decided not to overly confuse
> the O.P. -- this essentially doubles the code size.

I think it is important, when someone new asks one of their first
questions, to just focus on answering the question at hand.

Someone brand-new to programming has a difficult time to learn:
ok...to repeat your program, you need a loop, and here's how the loop
works, and you need to initialize your variables, and also it's a good idea
to check your input and...

Too many things thrown at them at once can be quite overwhelming.

Simply ignoring the input issue for now is fine. As they work with their
code, they will probably hit a wrong key occassionally, and notice that the
program produces and error message. It's a good thing, to have that type of
experience. If it becomes annoying because it happens often, or if they
become curious about whether there is a way to avoid such error messages,
they will probably come back and ask about that then, when they are more
ready to learn about that.

"Say, thanks for your help with the loop thing. I've been working on my
code and I noticed that if I enter a value that isn't an integer, it causes
problems in my program..."

When they ask about it, is when they are ready to learn about it. You don't
have to give them perfect code as a response to early programming
questions.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/






More information about the Python-list mailing list