Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64291

Re: question about input() and/or raw_input()

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
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; 'source,': 0.04; 'output': 0.05; 'preferably': 0.05; 'arguments': 0.09; 'difference,': 0.09; 'input,': 0.09; 'output,': 0.09; 'subject:()': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'gui': 0.12; 'jan': 0.12; '2.7.3': 0.16; 'basic.': 0.16; 'command-line': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hex': 0.16; 'none.': 0.16; 'personally,': 0.16; 'prefer.': 0.16; 'simplest': 0.16; 'wrote:': 0.18; 'command': 0.22; '>>>': 0.22; 'input': 0.22; 'example': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '(or': 0.24; 'cc:2**0': 0.24; 'compare': 0.26; 'least': 0.26; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; "doesn't": 0.30; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'linux.': 0.31; 'pipe': 0.31; 'procedures.': 0.31; 'run': 0.32; 'quite': 0.32; 'basic': 0.35; 'problem.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'possible': 0.36; 'should': 0.36; 'two': 0.37; 'easiest': 0.38; 'pm,': 0.38; 'that,': 0.38; 'ability': 0.39; 'aspects': 0.39; 'how': 0.40; 'read': 0.60; 'most': 0.60; 'skip:n 10': 0.64; 'more': 0.64; 'between': 0.67; 'statement,': 0.68; 'obvious': 0.74; 'fortunately': 0.84; 'irrelevant': 0.84; "they'd": 0.84; 'absolutely': 0.87; 'do:': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=BAddxpobvnlxQoy4nB68gpUt7lpzfN9lLwNMP3PQcBo=; b=lwVU5iFF+FzDi8xjXC60mX9/vWmW/fdkvn7MMdFxftN/hxUUyrnA4K6CB36IV6ecuR yG60JDcxX3Rwayg26uIFY/hLZLE2Ltk9VsHjxYs99MgNfgXmajmAh4ycW0NfPZnj2QjA g47Ts1Xv+7vj8t6trmuFaYMB9mMRTsBUzTAjCurIgTwBXq9pg/YdOzK5scj5RD8f1JAU 4snWP5b55GAQoR72DZ1k+GE4W1JcjQM0+NNUpU8ivdxz0xLgraC20apBHUTbUHNIbW9K WqP2e60fD5zjnjCSd5ibEKbFyqm0U+5/6hGm9T0msLRYq6lm4Ecv49Wbv57D97joJGTv gB7A==
MIME-Version 1.0
X-Received by 10.66.155.102 with SMTP id vv6mr12484063pab.89.1390127991022; Sun, 19 Jan 2014 02:39:51 -0800 (PST)
In-Reply-To <52663f72-8c61-4868-9887-7e980d90ec61@googlegroups.com>
References <roy-97803E.13302018012014@news.panix.com> <2b7f1a5d-4145-4f7d-be47-72d5eb207391@googlegroups.com> <mailman.5701.1390105305.18130.python-list@python.org> <07dc8493-fb43-47b4-b080-7bc1ae3d6681@googlegroups.com> <mailman.5702.1390107607.18130.python-list@python.org> <52663f72-8c61-4868-9887-7e980d90ec61@googlegroups.com>
Date Sun, 19 Jan 2014 21:39:50 +1100
Subject Re: question about input() and/or raw_input()
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5705.1390127995.18130.python-list@python.org> (permalink)
Lines 47
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1390127995 news.xs4all.nl 2933 [2001:888:2000:d::a6]:58241
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64291

Show key headers only | View raw


On Sun, Jan 19, 2014 at 7:26 PM, Rustom Mody <rustompmody@gmail.com> wrote:
> If you want to give an irrelevant example at least give a correct one :D
> the difference between str and hex is an arcane difference (Ive never used hex)
> the difference between functions and procedures is absolutely basic.

They don't give the same result for every possible input, any more
than your two do:

>>> foo(1.234567890123456)
2.23456789012
>>> bar(1.234567890123456)
2.234567890123456

(Tested on 2.7.3 on Linux. YMMV.)

There's no difference in Python between functions and procedures. It's
all functions, and some of them implicitly return None. If there were
a difference, what would this be?

def none_if(value, predicate):
    if not predicate(value): return value

Personally, I'm quite happy with Python and the print function. (Or
statement, if you prefer. Same difference.) The most fundamental
aspects of any program are input, output, and preferably some
computation in between; and the most fundamental forms of input are
the command line / console and the program's source, and the most
basic output is the console. So the most basic and obvious program
needs:

1) Access to the command-line arguments
2) The ability to read from the console
3) Some means of writing to the console.

Not every program will need all that, but they'd be the most obvious
and simplest methods of communication - especially since they're the
three that are easiest to automate. How do you run a GUI program
through automated testing? With difficulty. How do you run a stdio
program through automated testing? Pipe it some input and compare its
output to the standard. And that means people should be accustomed to
using print, and sys.argv, and (raw_)input.

Fortunately Python doesn't have ob_start() / ob_get_clean() to tempt
people to use print when they should use return. So there's no
problem.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

question about input() and/or raw_input() Roy Smith <roy@panix.com> - 2014-01-18 13:30 -0500
  Re: question about input() and/or raw_input() Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-18 18:41 +0000
  Re: question about input() and/or raw_input() Emile van Sebille <emile@fenx.com> - 2014-01-18 10:49 -0800
  Re: question about input() and/or raw_input() Peter Otten <__peter__@web.de> - 2014-01-18 20:05 +0100
  Re: question about input() and/or raw_input() Terry Reedy <tjreedy@udel.edu> - 2014-01-18 16:33 -0500
    Re: question about input() and/or raw_input() Grant Edwards <invalid@invalid.invalid> - 2014-01-19 16:14 +0000
      Re: question about input() and/or raw_input() Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-19 12:12 -0500
        Re: question about input() and/or raw_input() Grant Edwards <invalid@invalid.invalid> - 2014-01-19 17:42 +0000
          Re: question about input() and/or raw_input() Chris Angelico <rosuav@gmail.com> - 2014-01-20 04:59 +1100
  Re: question about input() and/or raw_input() Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-18 21:17 -0500
  Re: question about input() and/or raw_input() Chris Angelico <rosuav@gmail.com> - 2014-01-19 13:46 +1100
  Re: question about input() and/or raw_input() Rustom Mody <rustompmody@gmail.com> - 2014-01-18 20:15 -0800
    Re: question about input() and/or raw_input() Chris Angelico <rosuav@gmail.com> - 2014-01-19 15:21 +1100
      Re: question about input() and/or raw_input() Rustom Mody <rustompmody@gmail.com> - 2014-01-18 20:43 -0800
        Re: question about input() and/or raw_input() Chris Angelico <rosuav@gmail.com> - 2014-01-19 15:59 +1100
          Re: question about input() and/or raw_input() Rustom Mody <rustompmody@gmail.com> - 2014-01-19 00:26 -0800
            Re: question about input() and/or raw_input() Chris Angelico <rosuav@gmail.com> - 2014-01-19 21:39 +1100
            Re: question about input() and/or raw_input() Ethan Furman <ethan@stoneleaf.us> - 2014-01-19 08:14 -0800
            Re: question about input() and/or raw_input() Chris Angelico <rosuav@gmail.com> - 2014-01-20 03:38 +1100
            Re: question about input() and/or raw_input() Ethan Furman <ethan@stoneleaf.us> - 2014-01-19 09:50 -0800
            Re: question about input() and/or raw_input() Chris Angelico <rosuav@gmail.com> - 2014-01-20 05:41 +1100
            Re: question about input() and/or raw_input() Ethan Furman <ethan@stoneleaf.us> - 2014-01-19 11:16 -0800
  Re: question about input() and/or raw_input() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-19 06:24 +0000
  Re: question about input() and/or raw_input() Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-19 18:07 +0000
    Re: question about input() and/or raw_input() Grant Edwards <invalid@invalid.invalid> - 2014-01-19 18:15 +0000
      Re: question about input() and/or raw_input() Roy Smith <roy@panix.com> - 2014-01-19 13:37 -0500
        Re: question about input() and/or raw_input() Chris Angelico <rosuav@gmail.com> - 2014-01-20 05:43 +1100
        Re: question about input() and/or raw_input() Grant Edwards <invalid@invalid.invalid> - 2014-01-19 19:11 +0000
        Re: question about input() and/or raw_input() Gene Heskett <gheskett@wdtv.com> - 2014-01-19 15:09 -0500
      Re: question about input() and/or raw_input() Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-19 19:17 +0000
      Re: question about input() and/or raw_input() Larry Martell <larry.martell@gmail.com> - 2014-01-19 12:24 -0700
      Re: question about input() and/or raw_input() Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-19 19:29 +0000
  Re: question about input() and/or raw_input() Gene Heskett <gheskett@wdtv.com> - 2014-01-19 15:12 -0500
  Re: question about input() and/or raw_input() Larry Martell <larry.martell@gmail.com> - 2014-01-19 13:22 -0700

csiph-web