(app)
Allow IPython to automatically convert integer literals to Integer.
Allow IPython to automatically convert integer literals to Integer.
Allow IPython to automatically convert integer literals to Integer .
def enable_automatic_int_sympification(app):
    """
    Allow IPython to automatically convert integer literals to Integer.
    """
    hasshell = hasattr(app, 'shell')

    import ast
    if hasshell:
        old_run_cell = app.shell.run_cell
    else:
        old_run_cell = app.run_cell

    def my_run_cell(cell, *args, **kwargs):
        try:
            # Check the cell for syntax errors.  This way, the syntax error
            # will show the original input, not the transformed input.  The
            # downside here is that IPython magic like %timeit will not work
            # with transformed input (but on the other hand, IPython magic
            # that doesn't expect transformed input will continue to work).
            ast.parse(cell)
        except SyntaxError:
            pass
        else:
            cell = int_to_Integer(cell)
        old_run_cell(cell, *args, **kwargs)

    if hasshell:
        app.shell.run_cell = my_run_cell
    else:
        app.run_cell = my_run_cell
def enable_automatic_int_sympification ( app ) : hasshell = hasattr ( app , 'shell' ) import ast if hasshell : old_run_cell = app . shell . run_cell else : old_run_cell = app . run_cell def my_run_cell ( cell , * args , * * kwargs ) : try : # Check the cell for syntax errors.  This way, the syntax error # will show the original input, not the transformed input.  The # downside here is that IPython magic like %timeit will not work # with transformed input (but on the other hand, IPython magic # that doesn't expect transformed input will continue to work). ast . parse ( cell ) except SyntaxError : pass else : cell = int_to_Integer ( cell ) old_run_cell ( cell , * args , * * kwargs ) if hasshell : app . shell . run_cell = my_run_cell else : app . run_cell = my_run_cell