1) Template: def function_name(optional, input, parameters):
pass;
2) Default Arguments: By assigning the default argument in the function's declaration, you are ensuring that the prefix input parameter will always have a value, even if one is not supplied when the function is called
Example:
def process_all_textures(texture_node, prefix='my_'):
print('Processed%s%s'%(prefix, texture_node));
process_all_textures(texture); //result: Processed my_file1
3) Positional Argument(位置参数): not real argument, just declare there has a argument and pass data.
4) keyword Arguments (关键字参数): Prefix value for argument so that even you do not pass value to the keyword argument, it still has value.
5) Two issues for arguments:
(1) Positional arguments must come before keyword arguments, both in the function declaration and when calling the function.
(2) An argument can be passed by position or by keyword, but not both.
6) Variable-Length Argument Lists with the * Operator
allow a developer to define a function with an arbitrary number of arguments.
7) Variable-Length Argument Lists with the ** Operator
tells the interpreters to pack all key-value pairs passed to the function into a dictionary.
No comments:
Post a Comment