[python] Figured out how to go from email.Message.Message to string

Discussion in 'Python' started by David Stockwell, Jun 17, 2004.

  1. It took a little bit of digging but I finally figured it out by looking in
    my /usr/local/lib/py* directory's python modules.

    Turns out in the Message.py module there is a __str__ method you can call to
    convert to a string. And when i read more I found out its doing a fancy
    flatten. I've seen references to flatten around so this will help reinforce
    in my mind what it means for a flat tened or flat python object.




    David
    -------
    Tracfone: http://cellphone.duneram.com/index.html
    Cam: http://www.duneram.com/cam/index.html
    Tax: http://www.duneram.com/index.html

    _________________________________________________________________
    Looking to buy a house? Get informed with the Home Buying Guide from MSN
    House & Home. http://coldwellbanker.msn.com/
     
    David Stockwell, Jun 17, 2004
    #1
    1. Advertising

  2. David Stockwell

    David Bolen Guest

    "David Stockwell" <> writes:

    > Turns out in the Message.py module there is a __str__ method you can
    > call to convert to a string. And when i read more I found out its
    > doing a fancy flatten. I've seen references to flatten around so this
    > will help reinforce in my mind what it means for a flat tened or flat
    > python object.


    Note that any object's __str__ method provides a default way to create
    a "nicely" printable string representation of that object, but you
    won't normally call that method directly. Instead, it will be called
    indirectly if you use the object in a print statement, or as an
    argument to the %s string formatting operator, or if you use the str()
    built-in method on that object.

    Also note that the __str__ implementation for Message includes a Unix
    formatted "From" line (the format used in some Unix mailbox files).
    If you just want the plain message, you may want to use the
    as_string() method on the Message object instead which has a parameter
    to conditionalize the from line (off by default).

    -- David
     
    David Bolen, Jun 17, 2004
    #2
    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. Steven T. Hatton
    Replies:
    1
    Views:
    319
    David Rubin
    Aug 15, 2004
  2. David Stockwell
    Replies:
    0
    Views:
    275
    David Stockwell
    Jun 7, 2004
  3. Clark Case
    Replies:
    0
    Views:
    304
    Clark Case
    Aug 4, 2004
  4. mkadlec
    Replies:
    1
    Views:
    356
    Alexey Smirnov
    May 15, 2007
  5. richard

    figured it out!

    richard, Dec 2, 2009, in forum: HTML
    Replies:
    6
    Views:
    575
    nice.guy.nige
    Dec 7, 2009
Loading...

Share This Page