Which class?

Fulvio fulvio at tm.net.my
Sat Oct 14 10:03:05 EDT 2006


***********************
Your mail has been scanned by InterScan MSS.
***********************


Hello,

Sorry, I very new in programming and the use of the classes still unknown.
I'm really interested to apply the right one as far as the results aren't as 
expected.

Here's the example:

from poplib import POP3
ProtocolError = 'Error in Protocol'  # handler for IMAP4 and POP3 errors

try:
    _pop = POP3(args[0])
    _pop.user(args[1])
except:
    raise ProtocolError
a.append( 'STAT = POP Server %s reply\n %s\n' %(args[0], _pop.pass_(args[2])))
(numMsgs, totalSize) = _pop.stat()
for cnt in range(1, numMsgs +1):
    #Need a cleanup for the envelope header  'Unix-From'

    try:
        msgs =_pop.top(cnt,0)[1]
    except:
        raise ProtocolError

# Here I'd like to have some part removed and I known that some class in email 
# will do the neat job without missing any of the needed detail

    hdrs = [k for itms in ('from', 'to', 'cc',
                'date', 'subject', 'reply-to', 'message-')
                for k in msgs if k.startswith(itms.capitalize())]

# This isn't the right risult. Some time missing one of the wanted item.

_pop.quit()

I've put my opinions as comments, in order to copy and try. The args contains 
(pop address, user, and password) respectively.
The list comprehension fails for some comparison, might be more accurate a 
regex, I just fill too complicated  for a simple scan and I know that there 
are already good classes that will do the right way. I just miss the learning 
how to use them.

This a part of a small program, which will attempt to organize all the emails, 
locals and remote in order to do spam removal and/or backup the good ones.
I'd like somebody to join, not for a speedy result but for a joy of exchanging 
technics and tricks.

F




More information about the Python-list mailing list