1. * and * * in function call:*: Tuple or list "appears" * *: Dictionary "haunt" >>>defCheck_web_server (host, Post, path): Host_info = (' www.python.org ', 80, '/') when invoked: Check_web_server (host_info[ 0], host_info[1], host_info[2])This type of writing is neither amplified (a dozen parameters) nor is it difficult to seeWhen using the * Number: Check_web_server (*host_info)Clean and elegantWhen host_info = {host= ' www.python.org ', post=80, path= '/'} with **:check_web_server (**host_info)key names to match
2. * and * * in function definition:Allows Python to support variable-length parameters, which can receive any number of parameters >>>defDaily_sales_total (*all_sales): total = 0.0 for Each_sale in all seles:total + = Float (each_sale) return total >>> daily_sales_total () >>> daily_sales_total (0.0) >>> Daily_sales_total (1.0, 2.0, 3.0) >>>defCheck_web_server (host, post, Path, *args, **kwargs): # This function must accept at least three initial parameters, and can accept any subsequent number of arguments or keyword arguments
I love the difference between Python's *arges and **kwarges.