Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: question about input() and/or raw_input() Date: Sun, 19 Jan 2014 17:42:55 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 64 Message-ID: References: NNTP-Posting-Host: c-24-118-110-103.hsd1.mn.comcast.net X-Trace: reader1.panix.com 1390153375 22405 24.118.110.103 (19 Jan 2014 17:42:55 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Sun, 19 Jan 2014 17:42:55 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) X-Received-Bytes: 3085 X-Received-Body-CRC: 3014462448 Xref: csiph.com comp.lang.python:64301 On 2014-01-19, Dennis Lee Bieber wrote: > On Sun, 19 Jan 2014 16:14:48 +0000 (UTC), Grant Edwards > declaimed the following: > >>On 2014-01-18, Terry Reedy 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