[PYTHON] Access the variables defined in the script from the REPL

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

Access the variables defined in the script from the REPL
Access the file with a relative path from the execution script.
What beginners learned from the basics of variables in python
Get the script path in Python
Access the Twitter API in Python
python: Use the variables defined in the string format as they are
Save the Pydrive authentication file in a different directory from the script
How to access environment variables in Python
Revived from "no internet access" in Python
[Blender] Use OpenGL from inside the script
Access Google Calendar from the iOS app
Mathematical statistics from the basics Random variables
Access files in the same directory as the executable
Display the script shortcut menu in the network editor
Call a Python script from Embedded Python in C ++ / C ++
Implement the REPL
Used from the introduction of Node.js in WSL environment
Output the time from the time the program was started in python
[python] Get the list of classes defined in the module
Get the return code of the Python script from bat
[Blender] Use the text drawing module from within the script
Select the required variables in TensorFlow and save / restore
Determine if an attribute is defined in the object
Automatically access the flow in enebular and pull the trigger
Access Github by specifying the SSH key in GitPython
Extract each Location from Stargazers in the Github repository
Create a script for your Pepper skill in a spreadsheet and load SayText directly from the script