Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71529
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| 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.014 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; '(at': 0.04; 'lines,': 0.07; 'string': 0.09; 'runs': 0.10; 'python': 0.11; 'characters:': 0.16; 'file-like': 0.16; 'iterates': 0.16; 'iterator': 0.16; 'looping': 0.16; 'wrote:': 0.18; 'basically': 0.19; 'question': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; '13,': 0.31; 'file': 0.32; 'objects': 0.35; 'received:google.com': 0.35; 'subject:New': 0.37; 'too': 0.37; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'subject:. ': 0.67; 'subject:For': 0.78; 'fin': 0.84; 'treating': 0.84 |
| 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=gyT7rorC5FTTWIOXUlcde2pJ6zjV3AA8QAlPZoZ2NjE=; b=dTySDlDnubPreESWHYzDVzt3lVC08EiJf9y0CWXCAlncz8ZoalcMyY4PpLOvWWTFMF 5ibgnapXbEV/WaP9OcK4RxkbE1FZM+31sGNJMR33oKPBfHm021utvCVRHS455vzzjjrr e5dQD3tXYQDpuJCYsquF8R1WF0Zt1q4FHQxIBle9VTD337Z3WTGBHxnFhJ2CN5E8uvFY N2X89R1Cxb8YIZPmI9xafpToiVyc2Z1UrAzEPPH0TLAWlvBW4CXk31SS23Un7HiAy/Oc T6nyTmy6/E5LLMReUU7Rz1Jn62+4NKzmiHJQZ9TCAhsfsNbhH8EgNJGHLx0ybOF+Br4w YNhA== |
| X-Received | by 10.68.134.198 with SMTP id pm6mr1237633pbb.9.1400039385591; Tue, 13 May 2014 20:49:45 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <2f08e970-1334-4e7f-ba84-14869708a73b@googlegroups.com> |
| References | <2f08e970-1334-4e7f-ba84-14869708a73b@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Tue, 13 May 2014 21:49:04 -0600 |
| Subject | Re: New to Python. For in loops curiosity |
| To | Python <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.9988.1400039394.18130.python-list@python.org> (permalink) |
| Lines | 16 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1400039394 news.xs4all.nl 2944 [2001:888:2000:d::a6]:36104 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:71529 |
Show key headers only | View raw
On Tue, May 13, 2014 at 9:38 PM, Leonardo Petry
<leonardo.petry.br@gmail.com> wrote:
> The loop below (at the bottom) runs each line of the file
>
> fin = open('wordplay.txt');
> user_input = raw_input('Enter some characters: ')
> count = 0
> for line in fin:
> word = line.strip()
> if(avoids(word, user_input)):
> count += 1;
>
> This is just too convenient.
> Basically my question is: Why is python not treating the contents of wordplay.txt as one long string and looping each character?
Because the iterator for file-like objects iterates over lines, not characters.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
New to Python. For in loops curiosity Leonardo Petry <leonardo.petry.br@gmail.com> - 2014-05-13 20:38 -0700 Re: New to Python. For in loops curiosity John Gordon <gordon@panix.com> - 2014-05-14 03:46 +0000 Re: New to Python. For in loops curiosity Rustom Mody <rustompmody@gmail.com> - 2014-05-13 20:48 -0700 Re: New to Python. For in loops curiosity Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-13 21:49 -0600 Re: New to Python. For in loops curiosity Ben Finney <ben@benfinney.id.au> - 2014-05-14 14:03 +1000 Re: New to Python. For in loops curiosity Roy Smith <roy@panix.com> - 2014-05-14 07:38 -0400 Re: New to Python. For in loops curiosity Ned Batchelder <ned@nedbatchelder.com> - 2014-05-14 09:41 -0400
csiph-web