[Python-Dev] cpython: #11731: simplify/enhance parser/generator API by introducing policy objects.

Georg Brandl g.brandl at gmx.net
Tue Apr 19 07:30:50 CEST 2011


On 18.04.2011 21:39, R. David Murray wrote:

>> > +Policy objects are the mechanism used to provide the email package with the
>> > +flexibility to handle all these disparate use cases,
>> 
>> Looks like something is missing from this sentence :)
> 
> Éric thought so too, but it reads fine to me.  Maybe it is colloquial
> grammar and I'm just blind to it.  I can't now remember what his suggested
> modification was, either.  I've rewritten it as:
> 
>     Policy objects give the email package the flexibility to handle all
>     these disparate use cases.

Sure, I was only asking because the original ended in a trailing comma.

>> > +   >>> from email import msg_from_binary_file
>> > +   >>> from email.generator import BytesGenerator
>> > +   >>> import email.policy
>> > +   >>> from subprocess import Popen, PIPE
>> > +   >>> with open('mymsg.txt', 'b') as f:
>> > +   >>>     msg = msg_from_binary_file(f, policy=email.policy.mbox)
>> > +   >>> p = Popen(['sendmail', msg['To'][0].address], stdin=PIPE)
>> > +   >>> g = BytesGenerator(p.stdin, email.policy.policy=SMTP)
>> 
>> That keyword arg doesn't look right.
> 
> Yep, I got that backward when I edited it.
>  
>> > +   >>> g.flatten(msg)
>> > +   >>> p.stdin.close()
>> > +   >>> rc = p.wait()
>> 
>> Also, if you put interactive prompts, please use them correctly ("..." prompt
>> and one blank line for the with block).
> 
> Éric had me fix one example of that already.  What do you mean by "one
> blank line" though?  Doctest doesn't require blank lines after the ...
> lines, does it?

Not sure what doctest requires, but in the actual interactive shell you'd have

>>> with ...:
...     do something
...
>>> next statement

It's not really important though.

Georg



More information about the Python-Dev mailing list