At 00:13 +0900 04/18/2009, Stephen J. Turnbull wrote:
>R. David Murray writes:
>
> > put Header objects into it.  I don't think the "overhead" of
> > having to do
> >
> >      message['Subject'] = Header('subject string')
>
>Hm.  Should a Header know which header it is?  Ie, should that be
>
>    message['Subject'] = Header('subject', 'subject string')
 ...

How about:

    message['Subject'] = 'subject string'
    message['To'] = ('joe', 'joe...@foo.com')

Since the Header does indeed know what it is, a Subject: Header could
expect a string for input, and an Address header could expect an address
tuple or list of them (and cope with possibly needing to coerce the
addr-spec into bytes with the ASCII codec).

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.
-- 
____________________________________________________________________
TonyN.:'                       <mailto:tonynel...@georgeanelson.com>
      '                              <http://www.georgeanelson.com/>
_______________________________________________
Email-SIG mailing list
Email-SIG@python.org
Your options: 
http://mail.python.org/mailman/options/email-sig/archive%40mail-archive.com

Reply via email to