A video in Blender of how to use Python scripting, an example of how to do so. I show how it can be done in a easy way with a comprehensive example.
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.