Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44023
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'string.': 0.05; 'string': 0.09; '22,': 0.09; 'input,': 0.09; 'parsed': 0.09; 'received:mail- vc0-f174.google.com': 0.09; 'python': 0.11; 'translation': 0.12; 'windows': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'str()': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'input': 0.22; 'mon,': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; '120': 0.31; 'received:209.85.220.174': 0.31; 'handled': 0.32; 'option': 0.32; 'run': 0.32; 'running': 0.33; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'received:209': 0.37; 'convention': 0.38; 'to:addr:python-list': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; "you're": 0.61; 'revealed': 0.68; 'disabled,': 0.84; 'you;': 0.84; 'essence': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=kvaZqbCN2dX9FL0M8Fju9xex8TcVe+SHT3DfSq2iGvk=; b=LRmqxX8oR1I3NdCGePA89O98rO3TWbZAO24vK9TTP8nodf9a5BFohWk63UU31g1eB7 N45mTHcYazxMGzgo81pZOxc2A/pFUXIri02Fnrh8qWg9esQiLixkiqHEcRb9B9X4c6rA +V7zCMFgBbySktIR0y60t2foc2fI2rb+Px/MLybQgcWAAqYz7dxwjJ6glavyb9vk/5EV 6X2TMNN14QKAkJLLc+0h7VutwL9qvQGNDHEYRXlqi+NVbXnctnDP15s4bFbhXVTG6jFu 9Ql0X2I283T9oakf1JhPfAxOQBBtkq5Oh/vRGEI3ZzaaYOyvyKXKF2yWgti3WFx5Dgla 2XJA== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.91.71 with SMTP id cc7mr14872555vdb.58.1366592171270; Sun, 21 Apr 2013 17:56:11 -0700 (PDT) |
| In-Reply-To | <bd744d80-9abe-439e-a193-7db869d4a027@googlegroups.com> |
| References | <bd744d80-9abe-439e-a193-7db869d4a027@googlegroups.com> |
| Date | Mon, 22 Apr 2013 10:56:11 +1000 |
| Subject | Re: Weird behaviour? |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.892.1366592174.3114.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366592174 news.xs4all.nl 2186 [2001:888:2000:d::a6]:51409 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44023 |
Show key headers only | View raw
On Mon, Apr 22, 2013 at 10:37 AM, <jussij@zeusedit.com> wrote: > Can someone please explain the following behaviour? > > If I run the macro using the -u (flush buffers) option the if statement always fails: > > C:\Temp>python.exe -u c:\temp\test.py > Please Input 120: > 120 > Value Inputed: 120 > No Here's the essence of your program: print(repr(raw_input())) You can use that to verify what's going on. Try running that with and without the -u option; note, by the way, that -u actually means "unbuffered", not "flush buffers". You're running this under Windows. The convention on Windows is for end-of-line to be signalled with \r\n, but the convention inside Python is to use just \n. With the normal use of buffered and parsed input, this is all handled for you; with unbuffered input, that translation also seems to be disabled, so your string actually contains '120\r', as will be revealed by its repr(). By the way, raw_input() already returns a string. There's no need to str() it. :) ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Weird behaviour? jussij@zeusedit.com - 2013-04-21 17:37 -0700
Re: Weird behaviour? Chris Angelico <rosuav@gmail.com> - 2013-04-22 10:56 +1000
Re: Weird behaviour? jussij@zeusedit.com - 2013-04-21 18:11 -0700
Re: Weird behaviour? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-22 01:19 +0000
Re: Weird behaviour? nn <pruebauno@latinmail.com> - 2013-04-22 07:29 -0700
Re: Weird behaviour? jussij@zeusedit.com - 2013-04-22 16:06 -0700
Re: Weird behaviour? Chris Angelico <rosuav@gmail.com> - 2013-04-23 10:04 +1000
Re: Weird behaviour? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 00:31 +0000
Re: Weird behaviour? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-22 01:05 +0000
Re: Weird behaviour? jussij@zeusedit.com - 2013-04-21 18:14 -0700
Re: Weird behaviour? Chris Angelico <rosuav@gmail.com> - 2013-04-22 11:13 +1000
csiph-web