Iterating into maildir or mbox

TheSaint nobody at nowhere.net.no
Thu Jun 9 07:55:08 EDT 2011


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



More information about the Python-list mailing list