New to Python - Easy way to open a text file
Max Steel
maxsteel at gmail.com
Fri Mar 30 15:19:33 EDT 2007
Hmm.. maybe it'd help if I explained that I'm playing with edna
http://edna.sourceforge.net/
I'll play with this simple code:
f = open(r'pathToFile)
for line in f:
# do something with the line of text such as print it.
f.close()
and this one from Skip:
f = open(plainfiles.href, "r")
print f.read()
and see if I can make a go of it.. I think it's the template portion that is
mixing me up.. the template is what's used to create the look of the html on
the edna server.
Thanks to all who replied so quickly, much appreciated!
.\\ax
"Marc 'BlackJack' Rintsch" <bj_666 at gmx.net> wrote in message
news:pan.2007.03.30.16.39.12.89800 at gmx.net...
> In <1175270675.296617.83380 at e65g2000hsc.googlegroups.com>, 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
More information about the Python-list
mailing list