On 2014-01-19, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: > On Sun, 19 Jan 2014 16:14:48 +0000 (UTC), Grant Edwards ><invalid@invalid.invalid> declaimed the following: > >>On 2014-01-18, Terry Reedy <tjre...@udel.edu> wrote: >>> On 1/18/2014 1:30 PM, Roy Smith wrote: >>>> Pardon me for being cynical, but in the entire history of the universe, >>>> has anybody ever used input()/raw_input() for anything other than a >>>> homework problem? >>> >>> Homework problems (and 'toy' programs, such as hangman), whether in a >>> programming class or elsewhere, are one of the intended use cases of >>> Python. How else would you get interactive input without the complexity >>> of a gui? >> >>sys.stdin.readline() > > At which point a simple: > > nm = raw_input("Enter your name: ") > print "Hello, ", nm > > turns into (to duplicate the behavior WRT line endings, and to minimize the > new features the student is exposed to) > > import sys > > sys.stdout.write("Enter your name: ") > nm = sys.stdin.readline() > nm.strip() > sys.stdout.write("Hello, ") > sys.stdout.write(nm) > sys.stdout.write("\n") > sys.stdout.flush()
The question was how to get input without using a GUI. I presented an answer. You then conflated "whether or not to use input" with "whether or not to use print" and proceeded to construct and knock down a very nice straw man. Kudos. import sys print "Enter your name: ", nm = sys.stdin.readline().strip() print "Hello, ", nm > Yes, a non-beginner would have been exposed to formatting operations > and been able to condense the three .write() calls into one... 1) I don't get why you jumped on the whole print vs. string formatting thing. We're not talking about print vs write. We're talking about whether or not people use input and raw_input. I've been writing Python programs for 15 years, and I've never used either input or raw_input. 2) I didn't claim that sys.stdin.readline() was as simple as using input. I didn't claim it was preferable. I merely presented it as a refutation to the argument that if you don't use input/raw_input then you have to use a GUI toolkit. -- Grant -- https://mail.python.org/mailman/listinfo/python-list