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


Groups > comp.lang.python > #20579

Re: Undoing character read from file

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.063
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'elif': 0.04; 'context.': 0.09; 'subject:file': 0.13; 'compile,': 0.16; 'expected,': 0.16; 'false:': 0.16; 'len(c)': 0.16; 'wanted.': 0.16; 'cc:addr:python- list': 0.16; 'this:': 0.16; 'wrote:': 0.18; 'issue.': 0.19; 'cc:no real name:2**0': 0.21; 'trying': 0.21; 'header:In-Reply-To:1': 0.22; 'way?': 0.23; 'code': 0.26; 'figure': 0.26; '"the': 0.26; 'all,': 0.27; 'putting': 0.28; 'print': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; "didn't": 0.30; 'actual': 0.32; 'break': 0.32; "won't": 0.33; 'header:User-Agent:1': 0.33; 'instead': 0.33; 'something': 0.35; 'response': 0.36; 'post': 0.36; 'question': 0.36; 'cc:2**1': 0.36; 'but': 0.37; 'received:192': 0.38; 'should': 0.38; 'subject:from': 0.39; 'your': 0.61; 'here': 0.64; 'header:Reply-To:1': 0.70; 'reply- to:no real name:2**0': 0.72; 'hate': 0.73; 'lose': 0.84; '10:38': 0.84; 'quoting.': 0.84; 'running,': 0.84; 'subject:read': 0.84; 'traceback,': 0.84; 'unclear': 0.91
Date Fri, 17 Feb 2012 22:58:52 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111109 Thunderbird/3.1.16
MIME-Version 1.0
To Emeka <emekamicro@gmail.com>
Subject Re: Undoing character read from file
References <CAOypoo53NuLCfju_YuYh6AHR4g0GuN=EbKnmh7KY-3nxbaOSLg@mail.gmail.com> <mailman.5904.1329435244.27778.python-list@python.org> <9q7217F6j0U3@mid.individual.net> <CAOypoo5Xcniogn_XwQBkhN9h5OsmHssN5do_m1-eXkoonFe3Aw@mail.gmail.com> <CAOypoo7JKnq4XebEUBT1zY-55DiHOQvGCA+Ejz_OqeMMAWrv+w@mail.gmail.com>
In-Reply-To <CAOypoo7JKnq4XebEUBT1zY-55DiHOQvGCA+Ejz_OqeMMAWrv+w@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:4IzW0GRVNYSqIew/TKsjwSqdwrWQlx9MTVIHSm1AUjY AXDz0LX09nRfjf0nniDyagnWG1r+/yPL2ZZZkzUZvFiwdMXfF6 Jm3uNoJyw8QmCOtZSU1cHz367tEtLHGnFu69uVJsdyGueVPZX6 QZkl2USWzUFxKYlqNrTPK4eUnz/cNbS4+YxXeprjPZw4t9vj6z tkWePl6BF2JMdZ5rc6WIUUtJxVbu2KRUupDiHDG8WQRQgoQfLR 8znEOFtxcmHr32aH2fuolaBZ9iPMJL5g+3hSPOh6a6Wd/VOG8W EptQCyW700MRMCwwYE/QkaCi/15U+ZL+oHuBRtzpDsVgtrD7OS d8jVE6tdpq3cT1fKpyJU=
Cc python-list@python.org, Neil Cerutti <neilc@norwich.edu>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To d@davea.name
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.5933.1329537548.27778.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1329537548 news.xs4all.nl 6864 [2001:888:2000:d::a6]:40998
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20579

Show key headers only | View raw


On 02/17/2012 10:38 PM, Emeka wrote:
> Hello All,
>
> Say I have something like this:
>
> mfile = open("cc.txt", "rb")
> mcount = 0
> mset = False
> while True:
> c = mfile.read(1)
> if c == "e" and mset is True and mcount == 0:
>      print c
>      mfile.seek(-1,1)
>      mcount = 1
>      continue
> elif c == "e" and mset is False and mcount == 0:
>      print c
>      mfile.seek(-1, 0)
>      mcount = 1
>      continue
> elif c == "e" and mcount == 1:
>      print c
>      mcount = 0
>      continue
> print c
>   if mset is False:
>      mset = True
> if len(c) == 0:
>      break
>
> cc.txt
>
> foor the this the been we hate to sh wiukr bee here today. But who are we
> to question
> him concerning this issue.
>
> Is the above code the right way?

You top-posted, instead of putting your response after whatever you were 
quoting.  So you lose all context.

Your code won't compile, and it's unclear just what you were trying to 
accomplish.  What do you mean by "the right way"?

Please post the actual code that you're running, and explain what you 
expected, what you got, and how it didn't do what you wanted.  In this 
case, you should give us the traceback, so it's obvious that you're 
trying to figure out how to indent.



-- 

DaveA

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


Thread

Re: Undoing character read from file MRAB <python@mrabarnett.plus.com> - 2012-02-16 23:31 +0000
  Re: Undoing character read from file Neil Cerutti <neilc@norwich.edu> - 2012-02-17 13:12 +0000
    Re: Undoing character read from file Dave Angel <d@davea.name> - 2012-02-17 22:58 -0500

csiph-web