File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -262,6 +262,16 @@ def translate(s, table):
262262 res = res + table [ord (c )]
263263 return res
264264
265+ # Capitalize a string, e.g. "aBc dEf" -> "Abc def".
266+ def capitalize (s ):
267+ return upper (s [:1 ]) + lower (s [1 :])
268+
269+ # Capitalize the words in a string, e.g. " aBc dEf " -> "Abc Def".
270+ # See also regsub.capwords().
271+ def capwords (s ):
272+ return join (map (capitalize , split (s )))
273+
274+
265275# Try importing optional built-in module "strop" -- if it exists,
266276# it redefines some string operations that are 100-1000 times faster.
267277# It also defines values for whitespace, lowercase and uppercase
Original file line number Diff line number Diff line change @@ -262,6 +262,16 @@ def translate(s, table):
262262 res = res + table [ord (c )]
263263 return res
264264
265+ # Capitalize a string, e.g. "aBc dEf" -> "Abc def".
266+ def capitalize (s ):
267+ return upper (s [:1 ]) + lower (s [1 :])
268+
269+ # Capitalize the words in a string, e.g. " aBc dEf " -> "Abc Def".
270+ # See also regsub.capwords().
271+ def capwords (s ):
272+ return join (map (capitalize , split (s )))
273+
274+
265275# Try importing optional built-in module "strop" -- if it exists,
266276# it redefines some string operations that are 100-1000 times faster.
267277# It also defines values for whitespace, lowercase and uppercase
You can’t perform that action at this time.
0 commit comments