Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56405 > unrolled thread

Re: parsing email from stdin

Started byAndreas Perstinger <andipersti@gmail.com>
First post2013-10-08 16:24 +0200
Last post2013-10-08 16:24 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: parsing email from stdin Andreas Perstinger <andipersti@gmail.com> - 2013-10-08 16:24 +0200

#56405 — Re: parsing email from stdin

FromAndreas Perstinger <andipersti@gmail.com>
Date2013-10-08 16:24 +0200
SubjectRe: parsing email from stdin
Message-ID<mailman.855.1381242709.18130.python-list@python.org>
On 08.10.2013 14:20, Antoon Pardon wrote:
> As I don't know what encoding these messages will be in, I thought it
> would be prudent to read stdin as binary data.
>
> Using python 3.3 on a debian box I have the following code.
>
> #!/usr/bin/python3
>
> import sys
> from email import message_from_file
>
> sys.stdin = sys.stdin.detach()
> msg = message_from_file(sys.stdin)

Looking at the docs, I've found there is also "message_from_binary_file" 
which works for me with your code.

http://docs.python.org/3/library/email.parser.html#email.message_from_binary_file

Bye, Andreas

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web