Well, another try Re: while c = f.read(1)
en.karpachov at ospaz.ru
en.karpachov at ospaz.ru
Sat Aug 20 00:42:06 EDT 2005
On 18 Aug 2005 22:21:53 -0700
Greg McIntyre wrote:
> f = open("blah.txt", "r")
> while True:
> c = f.read(1)
> if c == '': break # EOF
> # ... work on c
>
> Is some way to make this code more compact and simple? It's a bit
> spaghetti.
>
> This is what I would ideally like:
>
> f = open("blah.txt", "r")
> while c = f.read(1):
> # ... work on c
for data in iter(lambda:f.read(1024), ''):
for c in data:
# ... work on c
--
jk
More information about the Python-list
mailing list