Apply English case rules to convert the first character of an ASCII string to upper case. This is an internal utility function to replace calls to str.capitalize() such that we can avoid changing behavior with changing locales. Parameters ---------- s : str Returns
(s)
| 70 | |
| 71 | |
| 72 | def english_capitalize(s): |
| 73 | """ Apply English case rules to convert the first character of an ASCII |
| 74 | string to upper case. |
| 75 | |
| 76 | This is an internal utility function to replace calls to str.capitalize() |
| 77 | such that we can avoid changing behavior with changing locales. |
| 78 | |
| 79 | Parameters |
| 80 | ---------- |
| 81 | s : str |
| 82 | |
| 83 | Returns |
| 84 | ------- |
| 85 | capitalized : str |
| 86 | |
| 87 | Examples |
| 88 | -------- |
| 89 | >>> from numpy._core.numerictypes import english_capitalize |
| 90 | >>> english_capitalize('int8') |
| 91 | 'Int8' |
| 92 | >>> english_capitalize('Int8') |
| 93 | 'Int8' |
| 94 | >>> english_capitalize('') |
| 95 | '' |
| 96 | """ |
| 97 | if s: |
| 98 | return english_upper(s[0]) + s[1:] |
| 99 | else: |
| 100 | return s |
nothing calls this directly
no test coverage detected
searching dependent graphs…