pound bang (#!) problem...

Ulrich Hoffmann uho at pizzicato.kbbs.org
Wed Dec 29 17:42:39 EST 1999


Orlando Vazquez <ovazquez at sprint.ca> writes:

Hi Orlando,

>If my UNIX skills serve me correctly running:
>   ./index.pyhtml
>should be the same as running:
>   ./preprocessor.py < index.pyhtml
>Right? But, when I do run index.pyhtm alone it just sits there and does
>not read the file. I'm probably making a silly mistake, but I can't see
>it..

My understanding is that in your case

./index.pyhtml

is expanded to:
    
./preprocessor.py index.pyhtml

Notice the missing redirection "<". Your program however ignores the
command line argument and instead tries to read from stdin. Since this
is still the keyboard, it waits for you to type something.

Try to parse command line arguments and open the file to read using
open and a distinct file object. 

(If you insist on reading stdin, then sys.stdin=open(sys.argv[1],"r") 
after some error checking should do the trick).

Regards,
	Ulli





More information about the Python-list mailing list