[Tutor] MIME Parsing/Generating (newbie question)

Magnus Lyckå magnus@thinkware.se
Thu May 8 20:54:02 2003


At 19:52 2003-05-08 -0400, Adam Kessel wrote:
>I'm a Python newbie--in fact, today is my first day. I've recently
>realized how difficult it is to remember what you meant in Perl a year or
>two after you wrote code, so I thought I'd give Python a try.

Good thinking! I did that six years ago, and I'm very happy
about that.

>So far I'm finding it tricky, but I know I need to unlearn some old
>habits first.

Yep. As Yoda said: "You have to unlearn what you have learnt."

>The first application I wanted to write would recognize HTML-only emails
>(e.g., hotmail), turn them into MIME multipart messages, and add a
>stripped version as the first part. (It would be a procmail filter).

That's a fairly ambitious thing to do one your first day.
(I bet you didn't write anything like that the first day
you coded Perl...)

>I am wondering if anyone can suggest a better way to do this. Also, can
>anyone recommend a good source for example code? I learn best by example,
>and the Python Library Reference has very few of them.

The Python cookbook, both the dead tree version from O'Reilly and
the one at activestate.com, is very useful. See
http://aspn.activestate.com/ASPN/Cookbook/Python/
and search for mime!

E.g. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/86676

But I'm not so sure that there are a lot of code examples for the
email module, since it's fairly recent.


--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program