Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7292
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | TheSaint <nobody@nowhere.net.no> |
| Newsgroups | comp.lang.python |
| Subject | Iterating into maildir or mbox |
| Followup-To | comp.lang.python |
| Date | Thu, 09 Jun 2011 19:55:08 +0800 |
| Organization | Aioe.org NNTP Server |
| Lines | 32 |
| Message-ID | <isqcau$4qv$1@speranza.aioe.org> (permalink) |
| NNTP-Posting-Host | iaBwBAVzn+HfzPBjpdhanQ.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:7292 |
Followups directed to: comp.lang.python
Show key headers only | View raw
Hello,
originally with python 2.4 ~ 2.7 (I think) iterating a maildir I was using
++++++++++++++++++++++++++Code+++++++++++++++++++++++++++++++++
try:
mbox= mailbox.PortableUnixMailbox(open(mbox,'r'))
except IOError:
# if file not found default is None
mbox= None
while mbox:
msg= next(mbox)
if msg is None: break
try:
m= msg.getheader('message-id')
if m: dx= m.strip('<>')
else: continue
except (IndexError, AttributeError, IOError):
# message without ID, put some mark
dx= str(time.time()).split('.')
dx= int(dx[0])*int(dx[1])
if dx in lmbox:continue
lmbox[dx]= dx
return lmbox
++++++++++++++++++++++++++Code+++++++++++++++++++++++++++++++++
I'm tryng to convert into Python 3.2, but I don't get why this is not
iterable anymore.
--
goto /dev/null
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Iterating into maildir or mbox TheSaint <nobody@nowhere.net.no> - 2011-06-09 19:55 +0800
csiph-web