Error in the email module documentation ?

  • Thread starter Adrien Di Mascio
  • Start date
A

Adrien Di Mascio

Hi all,

While reading the email module documentation, I found an error in a
small example given for the as_string() method of the Message class:
Here is the given code :

(URL : http://python.org/doc/current/lib/module-email.Message.html)

from cStringIO import StringIO
from email.Generator import Generator
fp = StringIO()
g = Generator(mangle_from_=False, maxheaderlen=60)
g.flatten(msg)
text = fp.getvalue()


The Generator constructor should take the StingIO instance as first
argument, am I wrong ?

Although this is only a small mistake, I think it should always
be fixed.

If I've missed something or if this error have already been reported,
just forget my mail.

Cheers,
 
T

Terry Reedy

Adrien Di Mascio said:
Hi all,

While reading the email module documentation, I found an error in a
small example given for the as_string() method of the Message class:
Here is the given code :

(URL : http://python.org/doc/current/lib/module-email.Message.html)

from cStringIO import StringIO
from email.Generator import Generator
fp = StringIO()
g = Generator(mangle_from_=False, maxheaderlen=60)
g.flatten(msg)
text = fp.getvalue()


The Generator constructor should take the StingIO instance as first
argument

Based on 12.2.3 Generating MIME documents:'''
class Generator( outfp[, mangle_from_[, maxheaderlen]])
The constructor for the Generator class takes a file-like object
called outfp for an argument. outfp must support the write() method
and be usable as the output file in a Python extended print statement.
''',
yes.
am I wrong ?
No

Although this is only a small mistake, I think it should always
be fixed.

Of course, Python docs strive for perfection. I did not find report
in Python/Doc bugs list so added to SourceForge as bug 817178
Email.message example missing arg

Terry J. Reedy
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top