Newlines in Function Definition for iPython Terminal

250 Views Asked by At

Using %paste, iPython takes newline characters in my function definition as the end of the function. This isn't an issue when I code from someone else's machine. I've looked through the config documentation and other sites; no luck.

def get_sheet(filepath, sheet_name):

    book = open_workbook(filepath)
    for name in book.sheet_names():
        if sheet_name in name.lower():
            sheet_name = name

    sheet = book.sheet_by_name(sheet_name)

    return sheet

SyntaxError: 'return' outside function

Many thanks =)

1

There are 1 best solutions below

0
Daniel Roseman On

Use %cpaste, which requires two dashes to exit the mode.