Every line of 'how to repeat a line of code 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.
691 def _format_code(code): 692 lines = code.splitlines() 693 format = "%%%dd %%s\n" % len(repr(len(lines) + 1)) 694 return "".join([format % (i + 1, line) for (i, line) in enumerate(lines)])
131 def mkline(self, line='', indent=None): 132 """Creates a properly set up line. 133 134 :line: the text to add 135 :indent: the indentation to have at the beginning 136 if None, it uses the default amount 137 138 """ 139 if indent is None: 140 indent = self.indent 141 # this deals with the fact that the first line is 142 # already properly indented 143 if '\n' not in self._rv: 144 try: 145 indent = indent[len(self._initial_indent):] 146 except IndexError: 147 indent = '' 148 indent = self._ind.spaces_to_indent(indent) 149 150 return indent + line
142 def _line(self, code, indent_count=0): 143 return "{indents}{code}".format( 144 indents=self.indent_symbols * indent_count, 145 code=code)
99 def strip_blank_lines(code): 100 lines = code.splitlines(keepends=False) 101 if not lines: 102 return "" 103 out = [] 104 it = iter(lines) 105 106 line = None 107 108 for line in it: 109 if line.strip(): 110 break 111 out.append(line) 112 for line in it: 113 out.append(line) 114 for line in reversed(out): 115 if not line.strip(): 116 out.pop() 117 return "\n".join(out)