print and input were warts
Posted Sep 1, 2007 0:42 UTC (Sat) by
AnswerGuy (guest, #1256)
In reply to:
Python 3.0a1 released by Lobais
Parent article:
Python 3.0a1 released
From an educational perspective, trying to teach Python as a first programming language, print and input/raw_input were warts.
In most languages they are functions --- taking a list of arguments,
possibly returning a value. In Python <3.0 print is a statement. As for input/raw_input --- don't even get me started on that. Let's just say that an "input()" function that defaults to evaluating it's results in your interpreter is a VERY BAD idea for beginning programmers! (I tell students to just add a statement at the beginning of their programs: input=raw_input ... and not to think about it 'til they're ready to learn about evaluation). Additionally print didn't really use sys.stdout consistently ... which causes other problems.
Sure, as idioms for experience programmers this is no big deal. Get used to it and move on. But for trying to teach some of the most basic *and* fundamental principles of programming it's inelegant to have some of the first things you teach be (warty) exceptions to the rest of the design.
I'm glad they made those changes to print and input/raw_input. input (evaluated) is dead, long live input (safe/data oriented)!
JimD
(
Log in to post comments)