Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'assignment': 0.07; 'duplicate': 0.07; 'problem?': 0.07; 'sys': 0.07; 'formatting': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:()': 0.09; 'to)': 0.09; 'subject:question': 0.10; 'def': 0.12; 'jan': 0.12; '>on': 0.16; 'elsewhere,': 0.16; 'message-id:@4ax.com': 0.16; 'modules,': 0.16; 'rarely': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'roy': 0.16; 'skip:> 20': 0.16; 'student': 0.16; 'wrote:': 0.18; 'module': 0.19; 'command': 0.22; '>>>': 0.22; 'input': 0.22; 'programming': 0.22; 'import': 0.22; '+0000': 0.22; 'print': 0.22; 'creating': 0.23; 'rapidly': 0.24; 'url:home': 0.24; 'subject:/': 0.26; 'header:X-Complaints-To:1': 0.27; 'point': 0.28; 'specified': 0.30; 'with,': 0.31; 'file': 0.32; 'class': 0.32; 'probably': 0.32; 'figure': 0.32; 'cases': 0.33; 'level.': 0.33; 'maybe': 0.34; "i'd": 0.34; 'anybody': 0.35; 'operations': 0.35; 'but': 0.35; 'charset:us-ascii': 0.36; 'level': 0.37; 'being': 0.38; 'received:76': 0.38; 'problems': 0.38; 'handle': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'gone': 0.61; 'new': 0.61; 'entire': 0.61; 'name:': 0.61; 'simple': 0.61; 'such': 0.63; 'needing': 0.65; 'smith': 0.68; 'programs,': 0.74; 'behavior': 0.77; '"learn': 0.84; 'complexity': 0.84; 'homework': 0.84; 'pardon': 0.84; 'route': 0.84; 'edwards': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: question about input() and/or raw_input() Date: Sun, 19 Jan 2014 12:12:39 -0500 Organization: IISS Elusive Unicorn References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-30-247.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390151568 news.xs4all.nl 2849 [2001:888:2000:d::a6]:34618 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64300 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() Yes, a non-beginner would have been exposed to formatting operations and been able to condense the three .write() calls into one... But the assignment has gone from "learn how to do simple input and output" into "learn about importable modules, learn how to handle line endings, and maybe figure out simple I/O in all of that" If that was the only route I'd rapidly end up creating a utility module with, to start with, a simple import sys def input(prompt=None): if prompt: sys.stdout.write(prompt) return sys.stdin.readline().strip() I rarely find a need to work at the sys.std*** level. Anything needing that level of control is probably using a data file specified on the command line and not interactive console... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/