[Edu-sig] The fate of raw_input() in Python 3000
Andre Roberge
andre.roberge at gmail.com
Fri Sep 8 03:49:46 CEST 2006
On 9/7/06, dblank at brynmawr.edu <dblank at brynmawr.edu> wrote:
> [Does this capture the essense of the discussion? I know some said that
> they don't use them, and this would not stop them from not using them :)
> -Doug]
Since I raised the issue in the first place, I'll just mention again
one additional point I raised which may have been overlooked. It is
generally recognized that input() == eval(raw_input()) is "not safe"
and therefore not a good example to give to beginners. Furthermore,
in the context of teaching, input() is, I believe, primarily used to
extract a number from a string. Thus, I would suggest that input
should be replaced by something like
def get_number(prompt):
s = raw_input(prompt)
try:
n = int(s)
except:
try:
n = float(s)
except:
print s + " is not a valid number."
return None
return n
Otherwise, while I am not using Python in a classroom, I certainly
agree with the summary below and support it.
André
>
> Core Python maintainers,
>
> Over on the Python edu-sig, we have been discussing a small aspect of PEP
> 3100 and its effects on teaching and classroom use. What is at issue is
> input() and raw_input(), which have been targeted for removal, and marked
> [done]:
>
> http://www.python.org/dev/peps/pep-3100/
>
> Guido suggested in his 2002 "Python Regrets" talk that
> eval(sys.stdin.readline()) and sys.stdin.readline() can be used for these,
> respectively. That's not quite true of course, because they also have a
> prompt. But even that aside, we believe that we would like to keep them
> as-is.
>
> I think that we have consensus among (the teachers of edu-sig) that many
> of us rely on the ease-of-use of the input() and raw_input() functions for
> one simple reason: input() and raw_input() can be used on day-1 of class,
> before discussing imports, streams, strings, eval, or functions. Complete
> replacement solutions require discussions of all of those topics.
>
> We believe that their removal goes against the spirit of Python in the
> classroom, and Python will be more complicated on the first day of class
> because of it.
>
> There were some suggestions that there could be better names for them,
> including "ask()" and "askexp()". In any event, we'd rather have them the
> way they are than not at all. Of course it is easy to add as a site.py
> implementation, but those of us that teach would rather use 100% Pure
> Python.
>
> For the complete edu-sig discussion, see:
>
> http://mail.python.org/pipermail/edu-sig/2006-September/006967.html
>
> Thank you for considering leaving this as is,
>
> The Teachers of Python edu-sig
>
>
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>
More information about the Edu-sig
mailing list