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


Groups > comp.lang.python > #98245

Re: raw_input and break

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: raw_input and break
Date Wed, 4 Nov 2015 14:54:36 -0700
Lines 27
Message-ID <mailman.29.1446674118.16136.python-list@python.org> (permalink)
References <h%u_x.29450$bN3.2901@fx06.am1>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de VtzTDXwn+BpCOw9dJyfnFwcbjgXgrAwNxaLYzTsLGD7w==
Return-Path <ian.g.kelly@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; 'received:209.85.223': 0.03; 'string.': 0.04; 'quotes:': 0.07; 'delimited': 0.09; 'loop.': 0.09; 'python': 0.10; 'wed,': 0.15; '"break"': 0.16; '"s"': 0.16; '"while': 0.16; 'denote': 0.16; 'guessing': 0.16; 'nameerror': 0.16; 'parentheses': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:break': 0.16; 'tried:': 0.16; 'wrote:': 0.16; 'variable': 0.18; '2015': 0.20; 'assign': 0.22; 'assuming': 0.22; 'latter': 0.22; 'trying': 0.22; 'header:In- Reply-To:1': 0.24; "doesn't": 0.26; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; "i'm": 0.30; 'code': 0.30; 'call.': 0.30; 'run': 0.33; 'choices': 0.33; 'received:google.com': 0.35; 'nov': 0.35; "isn't": 0.35; 'there': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'does': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'press': 0.61; 'here.': 0.62; 'here': 0.66; 'gotten': 0.76; 'to:name:python': 0.84; 'spell': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=1gbrg2rqc/TocK12DyOPwBgHDffDGaOT05PeYIfuW8g=; b=xMiIz5JgkM0ktLnrcyQR2uNpoXvHDvgwWkLmC4vyNowPI+E+1wLmYHTOQgF9kGi8y7 9ADMoIMzeNaEthT+UHsKe4Fu5sfNtinqNBMR7GlNL/6nQWmcYl4cezQS7mqi6kbfsCI4 GQQQs0MbwPKGUG2zQSC/sHMj6nY67FekH09lrbUkBL2f6HtX+FJ9MxeL+MgyQn/TAmpv UKbrC36MPAk9xK5tdggthspxzzbbmBkE7eo4CuxwiMjo+fVWnZX4XJWAI+eWQd7goXPc LPMGdVWs1uR9HqG0cXAu0oai+N5YGNcZkWsDjPCssyCTUeS4liCdBHMv080gJCWTNzb8 PL3A==
X-Received by 10.107.135.28 with SMTP id j28mr5675586iod.188.1446674115454; Wed, 04 Nov 2015 13:55:15 -0800 (PST)
In-Reply-To <h%u_x.29450$bN3.2901@fx06.am1>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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>
Xref csiph.com comp.lang.python:98245

Show key headers only | View raw


On Wed, Nov 4, 2015 at 2:44 PM,  <input/ldompeling@casema.nl> wrote:
> I have an continues loop with "while True:"
> Now I want to use "raw_input" and when I press "s" on the keybord that it will
> "break" the continues loop.
>
> I tried:
> choices = raw_input

This doesn't call raw_input. For that you need to write raw_input(),
where the parentheses indicate a function call. All the above does is
find the raw_input function and assign that function to the name
"choices".

> if choises == s:

Strings in Python are delimited with quotes: "s", not just s. The
latter is going to try to look up a variable named s, not denote a
string. Also, it's important to spell the variable here in the same
way that you did above. Above you have a c where here there is an s.
I'm assuming that this isn't exactly what you ran, because you most
likely would have gotten a NameError here. Please copy and paste
exactly the code that you're trying to run rather than retyping it.

> break

This needs to be indented. Not indenting it would be a SyntaxError, so
again I'm guessing that this isn't actually what you ran.

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


Thread

raw_input and break input/ldompeling@casema.nl - 2015-11-04 21:44 +0000
  Re: raw_input and break Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-04 14:54 -0700
  Re: raw_input and break Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-04 16:56 -0500
    Re: raw_input and break input/ldompeling@casema.nl - 2015-11-04 22:37 +0000
      Re: raw_input and break Steven D'Aprano <steve@pearwood.info> - 2015-11-05 11:44 +1100
  Re: raw_input and break tian.su.yale@gmail.com - 2015-11-04 21:39 -0800
    Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 09:22 +0000
      Re: raw_input and break Peter Otten <__peter__@web.de> - 2015-11-05 11:01 +0100
        Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 10:40 +0000
          Re: raw_input and break Peter Otten <__peter__@web.de> - 2015-11-05 12:38 +0100
            Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 12:59 +0000
              Re: raw_input and break Peter Otten <__peter__@web.de> - 2015-11-05 15:16 +0100
                Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 14:34 +0000
                Re: raw_input and break Peter Otten <__peter__@web.de> - 2015-11-05 18:06 +0100
                Re: raw_input and break input/ldompeling@casema.nl - 2015-11-05 17:28 +0000
                Re: raw_input and break Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-05 20:09 -0500
                Re: raw_input and break input/ldompeling@casema.nl - 2015-11-06 05:08 +0000
                Re: raw_input and break input/ldompeling@casema.nl - 2015-11-06 11:50 +0000
                Re: raw_input and break Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-06 08:25 -0500

csiph-web