The_init_() method has the parameter log=None. This is called a default parameter.
(See Chapter 11.) It means that when you make an instance of the Spider class, you can specify a parameter for log, but you don't have to. If you don't, the instance automatically uses None as the value for log.
Default parameters give you choices and make your code more flexible. Because of the default log parameter, a number of different options for logging can be used with the Spider class.
REMEMBER The other side of the coin is that if you use a default parameter, you need to write code to test for the default value. In the Spider class, this code is part of the_init_() method. It assigns the log_stdout() function to self.log (if the user doesn't specify a value for log). In contrast, get_page() requires a log argument and therefore doesn't need to check for a default value.
Was this article helpful?