[Python-ideas] Adding "Typed" collections/iterators to Python

Terry Reedy tjreedy at udel.edu
Tue Dec 20 00:10:55 CET 2011


On 12/18/2011 9:24 PM, Nathan Rice wrote:

>> Another bad example, since that's just a really verbose way of writing
>> my_string.capitalize().
>
> The python interpreter says otherwise...
>
>>>> foo = "line 1\nline 2\nline 3"
>>>> foo.capitalize()
> 'Line 1\nline 2\nline 3'
>>>> "\n".join(s.capitalize() for s in foo.split("\n"))
> 'Line 1\nLine 2\nLine 3'

Using the right method (as Nick corrected himself):
 >>> foo.title()
'Line 1\nLine 2\nLine 3'

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list