On Fri, Mar 13, 2009 at 9:59 PM, Lie Ryan
<lie.1296@gmail.com> wrote:
Steven D'Aprano wrote:
Email being sent locally may contain zero @ signs, and email being sent externally can contain one or more @ signs. Andy's code:
user, hostname= address.split('@', 1, True)
will fail on syntactically valid email addresses like this:
fred(away @ the pub)@example.com
From Wikipedia:
RFC invalid e-mail addresses
* Abc.example.com (character @ is missing)
* Abc.@example.com (character dot(.) is last in local part)
* Abc..123@example.com (character dot(.) is double)
* A@b@c@example.com (only one @ is allowed outside quotations marks)
* ()[]\;:,<>@example.com (none of the characters before the @ in this example, are allowed outside quotation marks)
Your example is valid email address if and only if it is enclosed in quotation mark: "fred(away @ the pub)"@example.com
That is valid but not because you can have nested email addresses like that.** The (...) part is a comment. I wouldn't bet that very many mail clients handle that according to the rfc. Many don't handle quoted strings either. And there are those that have a narrow view of which characters (Hint: if you don't want to get mail from hotmail users, just make sure your email address has '/' in it.)
http://www.ietf.org/rfc/rfc0822.txt
**Way back people wrote nested email addresses with % replacing the @ in the nested address (
sna%foo@bar). I haven't seen that for a while.
On topic:
Making split more complicated seems like overspecialization. Wouldn't a generic padding function be more useful? FWIW, this has been discussed before.
http://bugs.python.org/issue5034
--- Bruce (sorry for the digression)