readline.parse_and_bind('C-k: "#\n"')
text = []
line = '#'
while line and line[-1] == '#':
    line = input('> ')
if line.endswith('#'):
    text.append(line[:-1])
else:
    text.append(line)
print('\n'.join(text))
Shift + Return to insert linebreak in python