tags:

views:

74

answers:

1

Given a list of e-mail addresses:

list = ('First Last <[email protected]>' , '[email protected]')

some of which contain first and last name, others which just contain an e-mail address, how can I loop through the list and extract a first and last name (if they exist), and the email address?

Thanks.

+9  A: 
import email.utils
map(email.utils.parseaddr, email_list)
This was really helpful. Thank you.
ensnare
@ensnare: You should accept the answer. If this is what you are looking for.
pyfunc