Tony Nelson writes: > How about: > > message['Subject'] = 'subject string' > message['To'] = ('joe', 'joe...@foo.com') > > Since the Header does indeed know what it is
How? Since there's no explicit constructor, in fact the Header doesn't know what it is until the Message tells it what it is. That means that the registry of Header types must be known to the Message class. That may not be a burden on the clients of email, but I can't see it as a warm fuzzy for the maintainers of email. > Internally, Message.__setitem__() would look up the name, making > and assigning the proper Headere subclass if missing, and pass that > object the data. The Header subclass knows what type of data it > expects and raises (ValueError?) if it gets something > inappropriate. I don't think the FLUFL will accept that. First of all, "Mama don' 'low no raisin's round heya." Second, the duck-typing on the 'To' example is a little hairy. Since in your model message['To'] *produces* a sequence of pairs when evaluated, I would expect it to require a sequence of pairs on input. But you seem to be suggesting that if it's a sequence but not a sequence of sequences, it should handle that by assuming it's a (name,addr) pair. Heck, maybe we should do something reasonable if it's not a sequence. I think this is *way* too magical for the basic API of email. I'm also bothered by the complexity of having Message accept responsibility for the validity of data to be input to Header, then delegate that responsiblity back to Header. Users don't care, I suspect, but maintainers will. There will be an extra frame for Message in any trace causing by Header raising ValueError (or whatever), which is annoying since Message should be just passing the argument on ... but it needs to be remembered or looked up, and there will always be the temptation for developers to add a little smarts to Message's handling of Header's arguments (especially in derived classes, eg, a ListPost class that optionally prepends "[listname] " to the front of a post). Finally, I know that if I'm away from the email package for more than 24 hours, I'll forget which order the display name and address come in. _______________________________________________ Email-SIG mailing list Email-SIG@python.org Your options: http://mail.python.org/mailman/options/email-sig/archive%40mail-archive.com