Return the number of initial spaces in a string. Note that tabs are counted as a single space. For now, we do *not* support mixing of tabs and spaces in the user's input. Parameters ---------- s : string Returns ------- n : int
(s)
| 75 | |
| 76 | |
| 77 | def num_ini_spaces(s): |
| 78 | """Return the number of initial spaces in a string. |
| 79 | |
| 80 | Note that tabs are counted as a single space. For now, we do *not* support |
| 81 | mixing of tabs and spaces in the user's input. |
| 82 | |
| 83 | Parameters |
| 84 | ---------- |
| 85 | s : string |
| 86 | |
| 87 | Returns |
| 88 | ------- |
| 89 | n : int |
| 90 | """ |
| 91 | |
| 92 | ini_spaces = ini_spaces_re.match(s) |
| 93 | if ini_spaces: |
| 94 | return ini_spaces.end() |
| 95 | else: |
| 96 | return 0 |
| 97 | |
| 98 | # Fake token types for partial_tokenize: |
| 99 | INCOMPLETE_STRING = tokenize.N_TOKENS |
nothing calls this directly
no outgoing calls
no test coverage detected