#!/usr/bin/env python3 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. """A function to correct the line up of strings Useful when you need a multi-line string but otherwise would look ugly in your code because of indentation """ __all__ = ['correct_string'] __author__ = "Cody A. Taylor ( codemister99@yahoo.com )" __version__ = "0.1" def correct_string(s): """Use an additional character to fix your multi-line strings >>> correct_string("|Here I am using the '|' character ... | to line up this string") 'Here I am using the '|' character\n to line up this string' """ l = s.split("\n") for index in range(len(l)): l[index] = l[index].strip()[1:] #ignore character at [0] return "\n".join(l)