When you are challenging CodeIQ or Project Euler, you may want to do a little calculation.
How to access the variables defined in the script from the REPL. I will introduce each method of Python and Ruby.
Python
Use ʻipython3. You can install it with
pip3 install ipython`.
i.py
# coding: utf-8
a = 10
b = 20
Run the script with the % run
command.
$ ipython3
In [1]: %run i.py
In [2]: a
Out[2]: 10
In [3]: b
Out[3]: 20
Ruby
Use Pry.
i.rb
a = 10
b = 20
binding.pry
$ pry i.rb
[1] pry(main)> a
=> 10
[2] pry(main)> b
=> 20
Recommended Posts