code to parse a file

Thomas Weholt thomas at
Thu Feb 10 10:37:32 EST 2000

> Pedro Silva wrote:
> Hi
> I had write some code in a Python Method, a Zope Product, that will
> open a file and will read line-by-line and check if some string is in
> that line, if yes, it will return the line to a variable.
> The code I write is:
>         f=open('/var/spool/news/articles/esoterica/geral/1','r')
>         for lines in f.readline():
>             if string.find('From:'):
>                 from=lines
>             if string.find('Subject:'):
>                 sub=lines
>             if string.find('Date:'):
>                 date=lines
>             if string.find('Xref:'):
>       ,2)
>                 for text in
>                         cont=text
>         return from,sub,date,cont
> Is this code correct to do what I pretend?
> If not, can anyone help me to solve this?
> Please send your answers to: psilva at
> Thanks,
> Pedro

If I`m not mistaken, your posting is written in, or at least sent as,
HTML. Not smart when posting to newsgroups. I don`t actually care, but
you`ll get alot of flak from text-based-newsreading-hardcore kinda
people. And most people, probably the same group, will not bother to
send answers directly to your email adress, but send it all to the
newsgroup. I`ve tried this and that`s how I know. ;->

Did I answer your python-question? Well ....


More information about the Python-list mailing list