| Jon Stewart on Thu, 2 Dec 2004 00:24:16 -0600 (CST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: [nimh-dev] scan is easy too |
> Thus spake Tom Plagge:
> > #!/usr/bin/env python
> >
> > import email, os, string
> >
> > pth = "/home/tplagge/Mail/inbox"
> >
> > def parse_from(msg):
> > return email.Utils.parseaddr(msg['From'])[0]
> >
> > def parse_date(msg):
> > date = email.Utils.parsedate(msg['Date'])
> > return string.zfill(str(date[1]),2) + "/" + string.zfill(str(date[2]),2)
> >
> > for file in os.listdir(pth):
> > f = open(pth + "/" + file, 'r')
> > if not file.startswith(",") and not file.startswith("."):
> > msg = email.message_from_file(f)
> > print file.rjust(5) + parse_date(msg).rjust(7) + " " + \
> > parse_from(msg)[0:17].ljust(19) + msg['Subject'][0:40]
>
> Do either of you know of a good book I could look at for learning the
> syntax? I can tell what this does by looking at it, but I'm not sure I
> could write something that worked properly without a Python reference.
I have O'Reilly's _Python in a Nutshell_, which is not a good tutorial,
but does tend to be a decent reference, in my limited experience. The
python.org site has a lot of good reference material, too.
Jon
--
Jon Stewart Advanced Los Angeles C++
stew1@xxxxxxxxxxx http://www.alacpp.org
_______________________________________________
nimh-dev mailing list
nimh-dev@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/nimh-dev