3 examples of 'indentation in python' in Python

Every line of 'indentation in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
577def get_indentation(line):
578 """Return leading whitespace."""
579 if line.strip():
580 non_whitespace_index = len(line) - len(line.lstrip())
581 return line[:non_whitespace_index]
582 else:
583 return ''
318def _handle_indent_inside_string(self, char, cursor, fullline, post):
319 # break string with a '\' at the end of the original line, always
320 # breaking strings enclosed by parens is done in the
321 # _handle_between_paren method
322 n = self.editor.tab_length
323 pre = '%s \\' % char
324 post += n * ' '
325 if fullline.endswith(':'):
326 post += n * " "
327 post += char
328 return post, pre
121def _IndentString(source_string, indentation):
122 """Indent string some number of characters."""
123 lines = [(indentation * ' ') + line
124 for line in source_string.splitlines(True)]
125 return ''.join(lines)

Related snippets