Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Steven D'Aprano
On Sat, 27 Jun 2009 19:55:17 +0200, Piet van Oostrum wrote: >> Terry Reedy (TR) wrote: > >>TR> Peter Otten wrote: >> Will your program handle empty lines of input correctly? > Strangely enough, it seems to do so, but why? Because there aren't any. When you read lines from

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Emile van Sebille
On 6/27/2009 1:25 PM MRAB said... Emile van Sebille wrote: On 6/27/2009 3:39 AM Angus Rodgers said... On Fri, 26 Jun 2009 18:58:27 -0700 (PDT), powah wrote: Thank you for your hint. This is my solution: f = open('test', 'r') for line in f: print line[0].upper()+line[1:], Will your progr

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread MRAB
Emile van Sebille wrote: On 6/27/2009 3:39 AM Angus Rodgers said... On Fri, 26 Jun 2009 18:58:27 -0700 (PDT), powah wrote: Thank you for your hint. This is my solution: f = open('test', 'r') for line in f: print line[0].upper()+line[1:], Will your program handle empty lines of input corr

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Emile van Sebille
On 6/27/2009 3:39 AM Angus Rodgers said... On Fri, 26 Jun 2009 18:58:27 -0700 (PDT), powah wrote: Thank you for your hint. This is my solution: f = open('test', 'r') for line in f: print line[0].upper()+line[1:], Will your program handle empty lines of input correctly? It will when the

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Peter Otten
Terry Reedy wrote: > Peter Otten wrote: > Will your program handle empty lines of input correctly? >>> Strangely enough, it seems to do so, but why? >> >> Because there aren't any. When you read lines from a file there will >> always be at least the newline character. Otherwise it would ind

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Piet van Oostrum
> Terry Reedy (TR) wrote: >TR> Peter Otten wrote: > Will your program handle empty lines of input correctly? Strangely enough, it seems to do so, but why? >>> >>> Because there aren't any. When you read lines from a file there will >>> always be at least the newline character. Other

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Terry Reedy
Peter Otten wrote: Will your program handle empty lines of input correctly? Strangely enough, it seems to do so, but why? Because there aren't any. When you read lines from a file there will always be at least the newline character. Otherwise it would indeed fail: Except possibly for the l

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread D'Arcy J.M. Cain
On Sat, 27 Jun 2009 11:54:43 +0100 Angus Rodgers wrote: > On Sat, 27 Jun 2009 11:39:28 +0100, I asked rhetorically: > >>f = open('test', 'r') > >>for line in f: > >>print line[0].upper()+line[1:], > > > >Will your program handle empty lines of input correctly? > > Strangely enough, it seems t

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Peter Otten
Angus Rodgers wrote: > Yes, I understood that, and it's logical, but what was worrying me > was how to understand the cross-platform behaviour of Python with > regard to the different representation of text files in Windows > and Unix-like OSs. (I remember getting all in a tizzy about this If you

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Sat, 27 Jun 2009 13:49:57 +0200, Peter Otten <__pete...@web.de> wrote: >Angus Rodgers wrote: > >> On Sat, 27 Jun 2009 13:02:47 +0200, Peter Otten >> <__pete...@web.de> wrote: >> >>>Angus Rodgers wrote: >>> On Sat, 27 Jun 2009 11:39:28 +0100, I asked rhetorically: >Will your prog

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Peter Otten
Angus Rodgers wrote: > On Sat, 27 Jun 2009 13:02:47 +0200, Peter Otten > <__pete...@web.de> wrote: > >>Angus Rodgers wrote: >> >>> On Sat, 27 Jun 2009 11:39:28 +0100, I asked rhetorically: >>> Will your program handle empty lines of input correctly? >>> >>> Strangely enough, it seems to do s

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Sat, 27 Jun 2009 12:13:57 +0100, I wrote: >Hmm ... the \r\n sequence at the end of a Win/DOS file seems to be >treated as a single character. For instance, if test001A.txt is this file: abc xyz Bd ef gH ij and test001E.py is this: f = open('test001A.txt', 'r') for line in f: print repr(

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Sat, 27 Jun 2009 12:13:57 +0100, I wrote: >the \r\n sequence at the end of a Win/DOS file Of course, I meant the end of a line of text, not the end of the file. (I promise I'll try to learn to proofread my posts. This is getting embarrassing!) -- Angus Rodgers -- http://mail.python.org/mai

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Sat, 27 Jun 2009 13:02:47 +0200, Peter Otten <__pete...@web.de> wrote: >Angus Rodgers wrote: > >> On Sat, 27 Jun 2009 11:39:28 +0100, I asked rhetorically: >> >>>Will your program handle empty lines of input correctly? >> >> Strangely enough, it seems to do so, but why? > >Because there aren'

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Peter Otten
Angus Rodgers wrote: > On Sat, 27 Jun 2009 11:39:28 +0100, I asked rhetorically: > >>On Fri, 26 Jun 2009 18:58:27 -0700 (PDT), powah >> wrote: >> >>>Thank you for your hint. >>>This is my solution: >>>f = open('test', 'r') >>>for line in f: >>>print line[0].upper()+line[1:], >> >>Will your pr

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Sat, 27 Jun 2009 11:39:28 +0100, I asked rhetorically: >On Fri, 26 Jun 2009 18:58:27 -0700 (PDT), powah > wrote: > >>Thank you for your hint. >>This is my solution: >>f = open('test', 'r') >>for line in f: >>print line[0].upper()+line[1:], > >Will your program handle empty lines of input co

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Fri, 26 Jun 2009 18:58:27 -0700 (PDT), powah wrote: >Thank you for your hint. >This is my solution: >f = open('test', 'r') >for line in f: >print line[0].upper()+line[1:], Will your program handle empty lines of input correctly? -- Angus Rodgers -- http://mail.python.org/mailman/listinf

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Fri, 26 Jun 2009 18:58:27 -0700 (PDT), powah wrote: >On Jun 26, 4:51 pm, Chris Rebert wrote: >> On Fri, Jun 26, 2009 at 12:43 PM, powah wrote: >> > How to change the first character of the line to uppercase in a text >> > file? >> > [...] >> >

Re: change the first character of the line to uppercase in a text file

2009-06-26 Thread powah
On Jun 26, 4:51 pm, Chris Rebert wrote: > On Fri, Jun 26, 2009 at 12:43 PM, powah wrote: > > How to change the first character of the line to uppercase in a text > > file? > > e.g. > > input is: > > abc xyz > > Bd ef > > gH ij > > > output sh

Re: change the first character of the line to uppercase in a text file

2009-06-26 Thread Scott David Daniels
powah wrote: How to change the first character of the line to uppercase in a text file? Here is an English hint on the above: The "How ... file" above is a noun phrase, and is not a sentence, never mind a question. Putting a question mark after the noun phrase does not make tha

Re: change the first character of the line to uppercase in a text file

2009-06-26 Thread Tim Chase
powah wrote: How to change the first character of the line to uppercase in a text file? e.g. input is: abc xyz Bd ef gH ij output should be: Abc xyz Bd ef GH ij While you're asking the Python list, I'd just use GNU sed: sed -i 's/./\U&/' myfile.txt I don'

Re: change the first character of the line to uppercase in a text file

2009-06-26 Thread Chris Rebert
On Fri, Jun 26, 2009 at 12:43 PM, powah wrote: > How to change the first character of the line to uppercase in a text > file? > e.g. > input is: > abc xyz > Bd ef > gH ij > > output should be: > Abc xyz > Bd ef > GH ij We're not in the business of doi

Re: change the first character of the line to uppercase in a text file

2009-06-26 Thread Emile van Sebille
On 6/26/2009 12:43 PM powah said... How to change the first character of the line to uppercase in a text file? e.g. input is: abc xyz Bd ef gH ij output should be: Abc xyz Bd ef GH ij How far have you gotten? Emile -- http://mail.python.org/mailman/listinfo/python-list

change the first character of the line to uppercase in a text file

2009-06-26 Thread powah
How to change the first character of the line to uppercase in a text file? e.g. input is: abc xyz Bd ef gH ij output should be: Abc xyz Bd ef GH ij -- http://mail.python.org/mailman/listinfo/python-list