common and simplest unit-testing protocol in python it' much more convenient than retyping all your tests at the interactive prompt will discuss other commonly used options for testing python code--as you'll seethe unittest and doctest standard library modules provide more advanced testing tools in additionthe __name__ trick is also commonly used when you're writing files that can be used both as command-line utilities and as tool libraries for instancesuppose you write file-finder script in python you can get more mileage out of your code if you package it in functions and add __name__ test in the file to automatically call those functions when the file is run standalone that waythe script' code becomes reusable in other programs unit tests with __name__ in factwe've already seen prime example in this book of an instance where the __name__ check could be useful in the section on arguments in we coded script that computed the minimum value from the set of arguments sent in (this was the file minmax py in "the min wakeup call!")def minmax(test*args)res args[ for arg in args[ :]if test(argres)res arg return res def lessthan(xy)return def grtrthan(xy)return print(minmax(lessthan )print(minmax(grtrthan )self-test code this script includes self-test code at the bottomso we can test it without having to retype everything at the interactive command line each time we run it the problem with the way it is currently codedhoweveris that the output of the self-test call will appear every time this file is imported from another file to be used as tool--not exactly user-friendly featureto improve itwe can wrap up the self-test call in __name__ checkso that it will be launched only when the file is run as top-level scriptnot when it is imported (this new version of the module file is renamed minmax py here)print(' am:'__name__def minmax(test*args)res args[ for arg in args[ :]if test(argres)res arg return res advanced module topics