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


Groups > comp.lang.python > #18181

Re: Help in rotate 13 program

Date 2011-12-29 11:39 -0500
From Dave Angel <d@davea.name>
Subject Re: Help in rotate 13 program
References <CANtuMdJMfLg4VXhuSowG-Tr1yzioACLWQqJHhgi49w4sJYSNWg@mail.gmail.com> <CAPTjJmp6V3rrh7x8SxS5Mg5r_oEhd2BpNosPFNYwxor=cxZH1A@mail.gmail.com> <CANtuMd+afyrO_Tuh4Vzr4z_pBEMwjwyU61LWEaxa62FBBJCM_Q@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.4225.1325176785.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 12/29/2011 11:25 AM, Sayantan Datta wrote:
> On Thu, Dec 29, 2011 at 5:34 PM, Chris Angelico<rosuav@gmail.com>  wrote:
>
>> On Thu, Dec 29, 2011 at 10:48 PM, Sayantan Datta<kenzo.zombie@gmail.com>
>> wrote:
>>>      for line in sys.stdin :
>>>        for char in line :
>>> sys.stdout.write(rotate13_letter(char))
>>>
>>> cat sample.html | python rot13.py rot13.html
>> You're reading from stdin, which is correct, but you're writing to
>> stdout and not redirecting it. You need to put an arrow before
>> rot13.html to indicate redirection:
>>
>> cat sample.html | python rot13.py>rot13.html
>>
>> Note though that 'cat' is superfluous here; all you need to do is
>> redirect input:
>> python rot13.py<sample.html>rot13.html
>>
>> Hope that helps!
>>
>> Chris Angelico
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
> did that, but the output file is still empty? Does the fault lie somewhere
> else?
>
Both Peter and Chris pointed out that you have the if __name__ == 
"__main__" line indented.  If that's true in your actual file, then the 
program does nothing useful.

Why not run it without output redirection, and see what it displays?  
And stick an unindented print line in there, just to see it do something.



-- 

DaveA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Help in rotate 13 program Dave Angel <d@davea.name> - 2011-12-29 11:39 -0500

csiph-web