J
Jason Tackaberry
Hi,
Since the rfc822 module was removed in Python 3, and is deprecated in
2.3, I am obviously trying to avoid using it.
But I'm having a hard time finding an equivalent to rfc822.AddressList
in the email module, which I want to use to parse a _list_ of addresses:
[('John Doe', '(e-mail address removed)'), ('Doe, Jane', '(e-mail address removed)')]
email.utils.parseaddr() only returns the first address in the list:
('John Doe', '(e-mail address removed)')
email.utils.getaddresses() expects a list or tuple, and I can't simply
pass it addrlist.split(', ') for obvious reasons, and anyway rather
defeats the purpose of using a helper function to handle the tricky
bits.
Now, email._parseaddr.AddrlistClass has this functionality:
[('John Doe', '(e-mail address removed)'), ('Doe, Jane', '(e-mail address removed)')]
But that's obviously not a documented, public interface. Amusingly,
even in 3.1, the code for AddrlistClass says:
Note: this class interface is deprecated and may be removed in
the future. Use rfc822.AddressList instead.
Is there some non-deprecated method I can use to parse an RFC 2822
address list?
Thanks,
Jason.
Since the rfc822 module was removed in Python 3, and is deprecated in
2.3, I am obviously trying to avoid using it.
But I'm having a hard time finding an equivalent to rfc822.AddressList
in the email module, which I want to use to parse a _list_ of addresses:
[('John Doe', '(e-mail address removed)'), ('Doe, Jane', '(e-mail address removed)')]
email.utils.parseaddr() only returns the first address in the list:
('John Doe', '(e-mail address removed)')
email.utils.getaddresses() expects a list or tuple, and I can't simply
pass it addrlist.split(', ') for obvious reasons, and anyway rather
defeats the purpose of using a helper function to handle the tricky
bits.
Now, email._parseaddr.AddrlistClass has this functionality:
[('John Doe', '(e-mail address removed)'), ('Doe, Jane', '(e-mail address removed)')]
But that's obviously not a documented, public interface. Amusingly,
even in 3.1, the code for AddrlistClass says:
Note: this class interface is deprecated and may be removed in
the future. Use rfc822.AddressList instead.
Is there some non-deprecated method I can use to parse an RFC 2822
address list?
Thanks,
Jason.