sholden at bellatlantic.net
Fri Feb 11 14:37:56 CET 2000
[posted and mailed]
OK. Let's assume that you run this program on the post you made, and
which I quote below. Not only does it pull out the headers you
apprently want, but it likely pulls out the headers you quote. Or
something else you didn't want.
It may well be possible to fix that up, but then you will start to run
into other pathological conditions, and you'll end up with the same sort
of mess that Microsoft regularly sells for hundreds of dollars a pop.
But it won't do exactly what you want. Why not go for the 100% solution?
>From your recent posts it seems like you are new to Python, and possibly
new to programming as well. This makes you lucky, as comp.language.python
is a terrifically helpful group.
However, I seem to remember that someone recently pointed you to the
"rfc822" module as a way of correctly parsing mail and news message
headers. Perhaps this was posted to the newsgroup and you aren't able
to use network news. In that case, go to deja.com and sign up for public
free access. The point is, Python comes along with so much supporting
stuff that it's easy to re-invent the wheel, as I did with my first Python
project -- only halfway through coding did I realise that the webchecker
tool did about 136% of what I was trying to do! That hasn't stopped me,
since it's still a great way to improve my Python skill.
You should check the Python documentation about the RFC822 module, and if
that isn't helpful enough, get a couple of books. There is a list of those
on http://www.python.org/. Personally I found "Learning Python" by Mark Lutz
and David Ascher an excellent introduction, and Lutz's "Programming Python"
to be useful for picking ideas out of. But remember that as with any new
programming language, fluency won't come in a day. Good luck -- and remember,
the [Python] library is your friend!
> Pedro Silva wrote:
> I want to find some words in a file, how can I do this in python?
> What I want is:
> I have a file, that is a text file that is in teh filesystem. I need to
> get some lines in that file, and for that I need to find some words. For
> example, in that file I know that I have the words: From, Subject, Date
> and Xref and I need the text that is after this words.
> How can I find these words?
> This is to show the content of a file, but like I want:
> From: Pedro
> Subject: Find Words
> Date: 11/02/2000
> Content: xxxxxxxxxxx
> Something like this!!!
> Can anyone help me?
> Please send your answers to: psilva at ruido-visual.pt
"If computing ever stops being fun, I'll stop doing it"
More information about the Python-list