MIMEText breaking the rules?

Discussion in 'Python' started by Dale Strickland-Clark, Aug 1, 2007.

  1. The email module's mimetext handling isn't what you might expect from
    something that appears to behave like a dictionary.

    $ python
    Python 2.5 (r25:51908, May 25 2007, 16:14:04)
    [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from email.mime.text import MIMEText
    >>> msg = MIMEText("A message")
    >>> msg["To"] = ""
    >>> msg["To"] = ""
    >>> print msg.as_string()

    Content-Type: text/plain; charset="us-ascii"
    MIME-Version: 1.0
    Content-Transfer-Encoding: 7bit
    To:
    To:

    A message
    >>>


    Having apparently REPLACED my recipient, what I've ended up with is both of
    them.

    --
    Dale Strickland-Clark
    Riverhall Systems - www.riverhall.co.uk
    Dale Strickland-Clark, Aug 1, 2007
    #1
    1. Advertising

  2. Dale Strickland-Clark

    Tim Roberts Guest

    Dale Strickland-Clark <> wrote:
    >
    >The email module's mimetext handling isn't what you might expect from
    >something that appears to behave like a dictionary.
    >...
    >Having apparently REPLACED my recipient, what I've ended up with is both of
    >them.


    This behavior is documented in Message.Message, from which MIMEText
    eventually inherits. If you want to start over, delete the item:

    del Msg["To"]

    I would have to say that the existing behavior is more intuitive for an
    email object.
    --
    Tim Roberts,
    Providenza & Boekelheide, Inc.
    Tim Roberts, Aug 3, 2007
    #2
    1. Advertising

  3. Tim Roberts wrote:

    > Dale Strickland-Clark <> wrote:
    >>
    >>The email module's mimetext handling isn't what you might expect from
    >>something that appears to behave like a dictionary.
    >>...
    >>Having apparently REPLACED my recipient, what I've ended up with is both
    >>of them.

    >
    > This behavior is documented in Message.Message, from which MIMEText
    > eventually inherits. If you want to start over, delete the item:
    >
    > del Msg["To"]
    >
    > I would have to say that the existing behavior is more intuitive for an
    > email object.


    Thanks for the info.

    --
    Dale Strickland-Clark
    Riverhall Systems - www.riverhall.co.uk
    Dale Strickland-Clark, Aug 6, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amy
    Replies:
    0
    Views:
    454
  2. Irmen de Jong
    Replies:
    1
    Views:
    659
    Irmen de Jong
    Jan 18, 2004
  3. Damjan

    Unicode in MIMEText

    Damjan, Nov 24, 2005, in forum: Python
    Replies:
    5
    Views:
    527
    Damjan
    Nov 28, 2005
  4. Robert
    Replies:
    0
    Views:
    300
    Robert
    Jan 18, 2006
  5. Noob
    Replies:
    9
    Views:
    574
    Tim Rentsch
    May 7, 2012
Loading...

Share This Page