Python: Parameters and default values

I’m still having trouble exactly “liking” Python. But there is something very beautiful about it which I can’t yet put my finger on.

Serendipitous Design

Functions like print and range have a varying number of arguments.

>>> help(print)
Help on built-in function print in module builtins:

    print(value, ..., sep=' ', end='\n', file=sys.stdout)

    Prints the values to a steam, or to sys.stdout be default.
    Optional keyword arguments:
    file: a file-like object (Stream); defaults to the current sys.stdout.
    sep: string inserted between values, default a space.
    end: string appended after the last value, default a newline.


The arguments of the print function are:

the value(s) to be printed

sep = ‘ ‘ –> defaults to a space between different arguments

end=’\n’ –> after the last argument is printed, a new line is started

file –>specifies where to print

The sep , end and file arguments are default parameter values that are executed without a specific value passed in. To change the value for one of these arguments, add the keyword and the desired characters after…

View original post 21 more words

%d bloggers like this: