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

Function leading_indent

IPython/core/inputtransformer2.py:34–48  ·  view source on GitHub ↗

Remove leading indentation. If the first line starts with a spaces or tabs, the same whitespace will be removed from each following line in the cell.

(lines)

Source from the content-addressed store, hash-verified

32 return lines
33
34def leading_indent(lines):
35 """Remove leading indentation.
36
37 If the first line starts with a spaces or tabs, the same whitespace will be
38 removed from each following line in the cell.
39 """
40 if not lines:
41 return lines
42 m = _indent_re.match(lines[0])
43 if not m:
44 return lines
45 space = m.group(0)
46 n = len(space)
47 return [l[n:] if l.startswith(space) else l
48 for l in lines]
49
50class PromptStripper:
51 """Remove matching input prompts from a block of input.

Callers

nothing calls this directly

Calls 1

groupMethod · 0.80

Tested by

no test coverage detected