Re: Any algorithm to preserve whitespaces?

Discussion in 'Python' started by Lie Ryan, Jan 19, 2013.

  1. Lie Ryan

    Lie Ryan Guest

    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, when it reassemble
    > the the words, it does it like this:
    >
    > lines.append(' '.join(words))
    >
    > The biggest problem is, even when the input file has many spaces, it
    > strips it down to one.


    replace:

    words = line.split()

    with:
    words = line.split(' ')

    > The whole script will look clumsy here. I have put it up on GitHub,
    > here is it:

    https://github.com/santosh/capitalizr.py/blob/master/capitalizr

    In general, when the script is just this short, it's better to put it
    directly on the message.
    Lie Ryan, Jan 19, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Santosh Kumar

    Any algorithm to preserve whitespaces?

    Santosh Kumar, Jan 19, 2013, in forum: Python
    Replies:
    0
    Views:
    134
    Santosh Kumar
    Jan 19, 2013
  2. Mitya Sirenef

    Re: Any algorithm to preserve whitespaces?

    Mitya Sirenef, Jan 19, 2013, in forum: Python
    Replies:
    0
    Views:
    135
    Mitya Sirenef
    Jan 19, 2013
  3. Santosh Kumar

    Re: Any algorithm to preserve whitespaces?

    Santosh Kumar, Jan 23, 2013, in forum: Python
    Replies:
    0
    Views:
    94
    Santosh Kumar
    Jan 23, 2013
  4. Peter Otten
    Replies:
    0
    Views:
    89
    Peter Otten
    Jan 23, 2013
  5. Dave Angel
    Replies:
    0
    Views:
    89
    Dave Angel
    Jan 23, 2013
Loading...

Share This Page