[Tutor] Stdin email question
Magnus Lyckå
magnus@thinkware.se
Sun May 18 03:48:02 2003
At 14:10 2003-05-17 -0400, Daniel Nash wrote:
>Ok so if I do this first,
>
>the_whole_thing = sys.stdin.read()
>
>then
>
>headers = rfc822.Message(sys.stdin)
>
>No longer works because of the file pointer
>
>How can I fix this?
Just put "sys.stdin.seek(0)" between. Then you can place
your reads in whatever order you like. "seek" will move
the current position in a file or file-like object. It's
like wind/rewind on a VCR. It has a sister called "tell"
that informs you of the current position.
--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program