##// END OF EJS Templates
Merge pull request #6205 from Carreau/momentjs...
Merge pull request #6205 from Carreau/momentjs use momentjs for nicer dates

File last commit:

r17481:8b6065cf
r17701:782acc94 merge
Show More
Raw Input in the Notebook.ipynb
190 lines | 5.6 KiB | text/plain | TextLexer
/ examples / IPython Kernel / Raw Input in the Notebook.ipynb

Using raw_input and %debug in the Notebook

The Notebook has added support for raw_input and %debug, as of 1.0.

In [1]:
# Python 3 compat
import sys
if sys.version_info[0] >= 3:
    raw_input = input
In [2]:
name = raw_input("What is your name? ")
name
What is your name? Sir Robin
Out[2]:
'Sir Robin'

Python 2-only: the eval input works as well (input is just eval(raw_input(prompt)))

In [3]:
fingers = input("How many fingers? ")
fingers, type(fingers)
How many fingers? 4
Out[3]:
(4, int)
In [4]:
def div(x, y):
    return x/y

div(1,0)
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-4-a5097cc0c0c5> in <module>()
      2     return x/y
      3 
----> 4 div(1,0)

<ipython-input-4-a5097cc0c0c5> in div(x, y)
      1 def div(x, y):
----> 2     return x/y
      3 
      4 div(1,0)

ZeroDivisionError: integer division or modulo by zero
In [5]:
%debug
> <ipython-input-4-a5097cc0c0c5>(2)div()
      1 def div(x, y):
----> 2     return x/y
      3 

ipdb> x
1
ipdb> y
0
ipdb> exit