Re: New to Python - Easy way to open a text file
- From: "Max Steel" <maxsteel@xxxxxxxxx>
- Date: Fri, 30 Mar 2007 14:56:54 -0500
nothing is "lame" to me , all help is appreciated :)
..\\ax
<kyosohma@xxxxxxxxx> wrote in message
news:1175282893.015117.154310@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Mar 30, 11:39 am, Marc 'BlackJack' Rintsch <bj_...@xxxxxxx> wrote:
In <1175270675.296617.83...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, kyosohma
wrote:
I'm not familiar with ezt formats, however reading a text file is a
breeze.
This sentence doesn't match the code that follow. It's really simpler
than that ``while`` loop.
f = open(r'pathToFile')
while True:
line = f.readline()
if not line: break
# do something with the line of text such as print it.
f.close()
f = open(r'pathToFile)
for line in f:
# do something with the line of text such as print it.
f.close()
Ciao,
Marc 'BlackJack' Rintsch
Yes, the "while" is lame, I admit it. But sometimes you just gotta go
old school!
Mike
.
- Follow-Ups:
- Re: New to Python - Easy way to open a text file
- From: Michael Tobis
- Re: New to Python - Easy way to open a text file
- References:
- New to Python - Easy way to open a text file
- From: Max Steel
- Re: New to Python - Easy way to open a text file
- From: kyosohma
- Re: New to Python - Easy way to open a text file
- From: Marc 'BlackJack' Rintsch
- Re: New to Python - Easy way to open a text file
- From: kyosohma
- New to Python - Easy way to open a text file
- Prev by Date: Tkinter menu question--how to pass arguments
- Next by Date: Re: Tkinter menu question--how to pass arguments
- Previous by thread: Re: New to Python - Easy way to open a text file
- Next by thread: Re: New to Python - Easy way to open a text file
- Index(es):
Relevant Pages
|