Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: TheSaint Newsgroups: comp.lang.python Subject: Re: Py3k,email header handling Followup-To: comp.lang.python Date: Thu, 12 May 2011 00:27:22 +0800 Organization: Aioe.org NNTP Server Lines: 38 Message-ID: References: <4dca92b1$0$29980$c3e8da3$5496439d@news.astraweb.com> NNTP-Posting-Host: fWnxL+1cyTk2MJBfK19VQg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.4.11 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5131 Steven D'Aprano wrote: > Before you re-write it, you should run 2to3 over it and see how much it > can do automatically: Widely done, only the results from some query has radically changed on favour of unicode. Errors raising about results which are not strings anymore. > I'm afraid I don't understand the question. Making an example : from poplib import POP3 as pop3 pop3.user('userid') pop3.pass_('password') numMsg, total = pop3.stat() for cnt in numMsgs: header = pop3.top(cnt) # here I'd like to pass the header to some function that will return # a dictionary filling # from', 'to', 'cc', 'bcc', 'date', 'subject', 'reply-to', 'message-id' # keys, if nothing the leave empty string or None dict = email.header,decode_header(header) # but might not my result # Should I subclass this? The same would be from the IMAP4 message parsing. Some different process would take, would it ? > If you have any more concrete questions, please ask. If these aren't concrete questions, forgive me, I perhaps got into wrong news group. In the other and I hugely apreciated your clues. I'll see the docs some more long to achieve a clear learning. -- goto /dev/null