printing - Print with automatic tab (Python) -
is there simple command or way -- let's call \magic -- having
print('hello!\magichello!')
produces follwing
hello! hello!
that is, makes next line indented precisely end of previous?
many thanks!
you wrapping string in function:
def magic(s): res, indent = [], 0 part in s.split('\magic'): res.append(' ' * indent + part) indent += len(part) return '\n'.join(res) print magic('hello!\magichello!')
which produces:
hello! hello!
Comments
Post a Comment