Python Quick Tip: Interactive Mode
Learn how to use the interactive mode in Python. This is a great way to test your code and play around with all the functions and variables in your file.
You can start any Python script with the
$ python -i my_script.py
This runs the script and starts the interactive Python shell. All of the code in the file is already loaded in this session, so you have access to all variables and functions.
Let's have a look at this example script:
# my_script.py a = 5 def my_function(): print("Hello") print("The script finished")
If we run this script with
-i, we can play around with the code afterwards. You can end the Python shell with
$ python -i my_script.py The script finished >>> a 5 >>> my_function() Hello >>> quit() $
Join My Newsletter! Get Python and ML tips emailed directly to your inbox. Each month you’ll get a summary of all the content I created, including the newest videos, articles, promotions, tips, and more.
Learn all the necessary basics to get started with TensorFlow 2 and Keras.
Learn all the necessary basics to get started with this deep learning framework.
Implement popular Machine Learning algorithms from scratch using only built-in Python modules and numpy.