Re: Newbie question - better way to do this?

2007-05-28 Thread Nis Jørgensen
Steve Howell skrev: def firstIsCapitalized(word): return 'A' = word[0] = 'Z' For someone who is worried about the impact of non-ascii identifiers, you are making surprising assumptions about the contents of data. Nis -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question - better way to do this?

2007-05-28 Thread Steve Howell
--- Nis Jørgensen [EMAIL PROTECTED] wrote: Steve Howell skrev: def firstIsCapitalized(word): return 'A' = word[0] = 'Z' For someone who is worried about the impact of non-ascii identifiers, you are making surprising assumptions about the contents of data. The function there,

Re: Newbie question - better way to do this?

2007-05-28 Thread Nis Jørgensen
says Newbie question - better way to do this. I was hinting at a better way to do what you did, which was supposedly a better way of doing what the newbie wanted. I disagree that word.istitle is the correct idiom - from the naming of the function in the original example, I would guess word[0

Re: Newbie question - better way to do this?

2007-05-28 Thread Steve Howell
--- Nis Jørgensen [EMAIL PROTECTED] wrote: I disagree that word.istitle is the correct idiom - from the naming of the function in the original example, I would guess word[0].isupper would do the trick. nitpick That would return something like this: built-in method isupper of str

Newbie question - better way to do this?

2007-05-27 Thread Eric
I have some working code, but I realized it is just the way I would write it in C, which means there is probably a better (more pythonic) way of doing it. Here's the section of code: accumulate = firstIsCaps = False accumStart = i = 0 while i len(words): firstIsCaps =

Re: Newbie question - better way to do this?

2007-05-27 Thread Gabriel Genellina
En Sun, 27 May 2007 10:44:01 -0300, Eric [EMAIL PROTECTED] escribió: I have some working code, but I realized it is just the way I would write it in C, which means there is probably a better (more pythonic) way of doing it. Here's the section of code: accumulate = firstIsCaps = False

Re: Newbie question - better way to do this?

2007-05-27 Thread Steven D'Aprano
On Sun, 27 May 2007 06:44:01 -0700, Eric wrote: words is a big long array of strings. What I want to do is find consecutive sequences of words that have the first letter capitalized, and then call doSomething on them. (And you can ignore the fact that it won't find a sequence at the very

Re: Newbie question - better way to do this?

2007-05-27 Thread Steve Howell
--- Eric [EMAIL PROTECTED] wrote: I have some working code, but I realized it is just the way I would write it in C, which means there is probably a better (more pythonic) way of doing it. Here's the section of code: accumulate = firstIsCaps = False accumStart = i = 0

Re: Newbie question - better way to do this?

2007-05-27 Thread John Machin
On May 28, 12:46 am, Steven D'Aprano [EMAIL PROTECTED] wrote: On Sun, 27 May 2007 06:44:01 -0700, Eric wrote: words is a big long array of strings. What I want to do is find consecutive sequences of words that have the first letter capitalized, and then call doSomething on them. (And you

Re: Newbie question - better way to do this?

2007-05-27 Thread Steve Howell
--- John Machin [EMAIL PROTECTED] wrote: (And you can ignore the fact that it won't find a sequence at the very end of words, that is fine for my purposes). [...] Bzzzt. Needs the following code at the end: if accumulator: doSomething(accumulator) FWIW the OP already

Re: Newbie question - better way to do this?

2007-05-27 Thread Steven D'Aprano
On Sun, 27 May 2007 14:55:42 -0700, John Machin wrote: On May 28, 12:46 am, Steven D'Aprano [EMAIL PROTECTED] wrote: On Sun, 27 May 2007 06:44:01 -0700, Eric wrote: words is a big long array of strings. What I want to do is find consecutive sequences of words that have the first letter

Re: Newbie question - better way to do this?

2007-05-27 Thread Steve Howell
--- Steven D'Aprano wrote: On Sun, 27 May 2007 14:55:42 -0700, John Machin wrote: Bzzzt. Bzzzt! Can we please refrain from buzzer sounds in this mostly civil forum, even if one beep deserves another?

Re: Newbie question - better way to do this?

2007-05-27 Thread Paul Rubin
Eric [EMAIL PROTECTED] writes: words is a big long array of strings. What I want to do is find consecutive sequences of words that have the first letter capitalized, and then call doSomething on them. (And you can ignore the fact that it won't find a sequence at the very end of words, that