473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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/
Jul 18 '05 #1
1 1556
"David Stockwell" <wi*******@hotmail.com> 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
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: John J. Lee | last post by:
1. Why do I get this in my minibuffer when I do C-c C-c in a python-mode buffer containing the following valid Python code? Wrong type argument: sequencep, cpython ----START #!/usr/bin/env...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
13
by: Wayne Folta | last post by:
I've been a long-time Perl programmer, though I've not used a boatload of packages nor much of the tacky OO. A couple of years ago, I decided to look into Python and Ruby. Python looked OK, but...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.