MCPcopy Create free account
hub / github.com/ipython/ipython / num_ini_spaces

Function num_ini_spaces

IPython/core/inputsplitter.py:77–96  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

75
76
77def 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:
99INCOMPLETE_STRING = tokenize.N_TOKENS

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected