[Tutor] Questions about stdin, stdout, lists and tuples

Sheila King sheila@thinkspot.net
Mon, 08 Jan 2001 13:04:14 -0800

Python newbie, here. I come from a C++/Pascal/VB type of background.

My first goal is to write some mail filtering scripts in Python to manage my
e-mail spam. My e-mail scripts will be fed the incoming e-mail on stdin and I
have to write my e-mails to stdout if I want them to be delivered through my

I have a couple of questions I want to ask, just to make sure I'm
understanding things clearly:

Here is a short practice script I just wrote:

import sys
line = sys.stdin.readline()
print line

It reads a single line from stdin and prints it to stdout.

My understanding, is that this is equivalent to the C++ program:
#include <iostream.h>
#include <string.h>

int main()
   string line;
   cout << line;
   return 0;

If anyone would like to confirm/deny/comment on my conclusions about
stdin/stdout, I would be interested. Am I overlooking any Python peculiarities
(such as the difference between "input" and "raw_input" or something along
those lines.)?

lists are like arrays, because I can reassign their values (they are not
immutable), whereas tuples are like const arrays, their values cannot be

Have I got that right?

Sheila King