sys.stdin and

Erik Max Francis max at
Mon Jan 20 08:26:59 CET 2003

Jimmie Fulton wrote:

> I'm unable to get any matches with re in a loop when the file I'm
> looping
> over is stdin.  When I use open(), it works fine.  Any hints?

No obvious differences are jumping out at me.  Maybe if you showed us
the file you're using and how you're invoking the script in either way?

By the way, a more idiomatic way to iterate over every line in a file

	while 1:
	    line = F.readline()
	    if not line:

In modern versions, you can just iterate over the file object itself:

	for line in F:

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Does the true light / Of love come in flashes
\__/ Sandra St. Victor
    CatCam /
 What do your pets do all day while you're at work?  Find out.

More information about the Python-list mailing list