Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20579
| Date | 2012-02-17 22:58 -0500 |
|---|---|
| From | Dave Angel <d@davea.name> |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5933.1329537548.27778.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Find similar | Unroll 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