Re: Any algorithm to preserve whitespaces?

2013-01-24 Thread Santosh Kumar
On 1/24/13, Peter Otten __pete...@web.de wrote: Santosh Kumar wrote: Yes, Peter got it right. Now, how can I replace: script, givenfile = argv with something better that takes argv[1] as input file as well as reads input from stdin. By input from stdin, I mean that currently when I

Re: Any algorithm to preserve whitespaces?

2013-01-24 Thread Peter Otten
Santosh Kumar wrote: On 1/24/13, Peter Otten __pete...@web.de wrote: Santosh Kumar wrote: Yes, Peter got it right. Now, how can I replace: script, givenfile = argv with something better that takes argv[1] as input file as well as reads input from stdin. By input from stdin, I

Re: Any algorithm to preserve whitespaces?

2013-01-24 Thread Santosh Kumar
But I can; see: http://pastebin.com/ZGGeZ71r On 1/24/13, Peter Otten __pete...@web.de wrote: Santosh Kumar wrote: On 1/24/13, Peter Otten __pete...@web.de wrote: Santosh Kumar wrote: Yes, Peter got it right. Now, how can I replace: script, givenfile = argv with something better

Re: Any algorithm to preserve whitespaces?

2013-01-24 Thread Peter Otten
Santosh Kumar wrote: But I can; see: http://pastebin.com/ZGGeZ71r You have messed with your cat command -- it adds line numbers. Therefore the output of cat somefile | ./argpa.py differs from ./argpa.py somefile Try ./argpa.py somefile to confirm my analysis. As to why your

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Santosh Kumar
I am in a problem. words = line.split(' ') preserve whitespaces but the problem is it writes an additional line after every line. And: words = line.split() works as I expect (does not adds addition line after every line) but does not preserves whitespaces. --

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Peter Otten
Santosh Kumar wrote: I am in a problem. words = line.split(' ') preserve whitespaces but the problem is it writes an additional line after every line. Strip off the newline at the end of the line with: line = line.rstrip(\n) words = line.split( ) --

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Dave Angel
On 01/23/2013 04:20 AM, Santosh Kumar wrote: I am in a problem. words = line.split(' ') preserve whitespaces but the problem is it writes an additional line after every line. Think about what you said. It might be clearer if you wrote: but the problem is it doesn't strip off the

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Santosh Kumar
Yes, Peter got it right. Now, how can I replace: script, givenfile = argv with something better that takes argv[1] as input file as well as reads input from stdin. By input from stdin, I mean that currently when I do `cat foo.txt | capitalizr` it throws a ValueError error: Traceback

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Michael Torrie
On 01/23/2013 07:56 AM, Santosh Kumar wrote: Yes, Peter got it right. Now, how can I replace: script, givenfile = argv with something better that takes argv[1] as input file as well as reads input from stdin. By input from stdin, I mean that currently when I do `cat foo.txt |

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Peter Otten
Santosh Kumar wrote: Yes, Peter got it right. Now, how can I replace: script, givenfile = argv with something better that takes argv[1] as input file as well as reads input from stdin. By input from stdin, I mean that currently when I do `cat foo.txt | capitalizr` it throws a

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Steven D'Aprano
Santosh Kumar wrote: Yes, Peter got it right. Peter? Which Peter? What's it that he got right? You have deleted all context from your post, so I have no idea what you are talking about. And whatever program you are using to post is stripping out threading information, so I can't tell what post

Re: Any algorithm to preserve whitespaces?

2013-01-23 Thread Dave Angel
On 01/23/2013 07:49 PM, Steven D'Aprano wrote: Santosh Kumar wrote: Yes, Peter got it right. Peter? Which Peter? What's it that he got right? You have deleted all context from your post, so I have no idea what you are talking about. Right. And whatever program you are using to post is

Re: Any algorithm to preserve whitespaces?

2013-01-19 Thread Lie Ryan
On 19/01/13 21:13, Santosh Kumar wrote: I have a working script which takes argv[1] as an input, deassembles each line, and then each word. Then after it capitalizes all its word (upcases the first letter) and then prints it out on the stdout. That script does the capitalization work fine, but,

Re: Any algorithm to preserve whitespaces?

2013-01-19 Thread Mitya Sirenef
On 01/19/2013 05:13 AM, Santosh Kumar wrote: I have a working script which takes argv[1] as an input, deassembles each line, and then each word. Then after it capitalizes all its word (upcases the first letter) and then prints it out on the stdout. That script does the capitalization work fine,