Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: Convert your script to module

  • Take one of your real scripts (from work or from a previous assignment). Create a backup copy.
  • Change the script so it can be import-ed as a module and then it won't automatically execute anything, but that it still works when executed as a script.
  • Add a new function to it called self_test and in that function add a few test-cases to your code using 'assert'.
  • Write another script that will load your real file as a module and will run the self_test.
  • Let me know what are the dificulties!