To inspect variables after running a .py file in an IPython session, you can follow these steps:
-
Start IPython: Open your terminal and start an IPython session by typing
ipython. - Run the Python File: Use the
%runmagic command to execute your Python script. For example:%run your_script.py - Inspect Variables: After running the script, all the variables defined in the script will be available in the IPython session. You can inspect them by simply typing their names. For example:
print(variable_name) - Use IPython Features: You can also use IPython’s built-in features like
whosto list all variables and their types:whos
This approach allows you to interactively explore and debug your script’s variables.