Newbie question - better way to do this?
Nis Jørgensen
nis at superlativ.dk
Mon May 28 11:16:20 EDT 2007
Steve Howell skrev:
> --- Nis Jørgensen <nis at superlativ.dk> 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, which I don't even remotely
> defend, had nothing to with the main point of the
> thread. Others pointed out that correct idiom here is
> word.istitle(), but the main point of the thread was
> how to prevent the newbie from essentially reinventing
> itertools.groupby.
The subject line 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].isupper"
would do the trick.
> If you want to point out holes in my logic about the
> impact of non-ascii identifiers (the above code,
> though bad, does not suggest a hole in my logic; it
> perhaps even adds to my case), can you kindly do it in
> a thread where that's the main point of the
> discussion?
Will do.
Nis
More information about the Python-list
mailing list