Python 3.6.5 (default, Jul 16 2018, 18:58:26) [GCC 5.5.0] on linux Type "copyright", "credits" or "license()" for more information. >>> def function(x,*z): print(x,z) >>> function(1) 1 () >>> def function(x,y,*z): print(x,y,z) >>> function(1) Traceback (most recent call last): File "", line 1, in function(1) TypeError: function() missing 1 required positional argument: 'y' >>> def function(x,y=2,*z): print(x,y,z) >>> function(1) 1 2 () >>> function(1,3) 1 3 () >>> function(1,3,4) 1 3 (4,) >>> function(1,3,z=(3,)) Traceback (most recent call last): File "", line 1, in function(1,3,z=(3,)) TypeError: function() got an unexpected keyword argument 'z' >>> function(1,3,*z=(3,)) SyntaxError: invalid syntax >>> function(1,3,z=3) Traceback (most recent call last): File "", line 1, in function(1,3,z=3) TypeError: function() got an unexpected keyword argument 'z' >>> function(1,3) 1 3 () >>> def f(x,y=2,*z,l=9) SyntaxError: invalid syntax >>> def f(x,y=2,*z,l=9): print(x,y,z,l); >>> f() Traceback (most recent call last): File "", line 1, in f() TypeError: f() missing 1 required positional argument: 'x' >>> f(2) 2 2 () 9 >>> f(2,l=list('abcde')) 2 2 () ['a', 'b', 'c', 'd', 'e'] >>> f(2,3,4l=list('abcde')) SyntaxError: invalid syntax >>> f(2,3,4,l=list('abcde')) 2 3 (4,) ['a', 'b', 'c', 'd', 'e'] >>> def f(x,y=2,**z,l=9): print(x,y,z,l); SyntaxError: invalid syntax >>> def f(x,y=2,*z,l): print(x,y,z,l); >>> f(2) Traceback (most recent call last): File "", line 1, in f(2) TypeError: f() missing 1 required keyword-only argument: 'l' >>> f(2,l=5) 2 2 () 5 >>> def f(x,y=2,*z,l,**klucze): print(x,y,z,l,klucze) >>> def f(x,y=2,*z,l,**klucze): print(x,y,z,l,klucze)f(2,l=5) KeyboardInterrupt >>> f(*list(range(8)),l=5) 0 1 (2, 3, 4, 5, 6, 7) 5 {} >>> f(*list(range(8)),l=5,**globals()) 0 1 (2, 3, 4, 5, 6, 7) 5 {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , 'function': , 'f': } >>> f(*list(range(8)),l=5,globals()) SyntaxError: positional argument follows keyword argument >>> f(list(range(8)),l=5,globals()) SyntaxError: positional argument follows keyword argument >>> f(list(range(8)),l=5) [0, 1, 2, 3, 4, 5, 6, 7] 2 () 5 {} >>> f(*list(range(8)),l=5) 0 1 (2, 3, 4, 5, 6, 7) 5 {} >>> f(*globals(),l=5) __name__ __doc__ ('__package__', '__loader__', '__spec__', '__annotations__', '__builtins__', 'function', 'f') 5 {} >>> s = globals() >>> s {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , 'function': , 'f': , 's': {...}} >>> for x in s : print(x) __name__ Traceback (most recent call last): File "", line 1, in for x in s : RuntimeError: dictionary changed size during iteration >>> s = globals().copy() >>> for x in s : print(x) __name__ __doc__ __package__ __loader__ __spec__ __annotations__ __builtins__ function f s x >>> >>> def f(x,y=2,*z,l,**klucze): print(x,y,z,l,klucze) >>> def f(x,y=2,*,l,**klucze): print(x,y,z,l,klucze) >>> f(*globals(),l=5) Traceback (most recent call last): File "", line 1, in f(*globals(),l=5) TypeError: f() takes from 1 to 2 positional arguments but 11 positional arguments (and 1 keyword-only argument) were given >>> f(globals(),l=5) Traceback (most recent call last): File "", line 1, in f(globals(),l=5) File "", line 1, in f def f(x,y=2,*,l,**klucze): print(x,y,z,l,klucze) NameError: name 'z' is not defined >>> def f(x,y=2,*,l,**klucze): print(x,y,l,klucze) >>> f(globals(),l=5) {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , 'function': , 'f': , 's': {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , 'function': , 'f': , 's': {...}, 'x': '__name__'}, 'x': 'x'} 2 5 {} >>> >>> >>> >>> >>> def m( x ) : return x**3.2 >>> m(9) 1131.2954233842977 >>> l = list(range(9)) >>> l [0, 1, 2, 3, 4, 5, 6, 7, 8] >>> for x in l : print(m(x)) 0.0 1.0 9.18958683997628 33.63473536961897 84.44850628946526 172.4662076826519 309.0893215187353 506.19019442693155 776.0468820533241 >>> map(m,l) >>> list(_) [0.0, 1.0, 9.18958683997628, 33.63473536961897, 84.44850628946526, 172.4662076826519, 309.0893215187353, 506.19019442693155, 776.0468820533241] >>> _ [0.0, 1.0, 9.18958683997628, 33.63473536961897, 84.44850628946526, 172.4662076826519, 309.0893215187353, 506.19019442693155, 776.0468820533241] >>> map(m,*l) Traceback (most recent call last): File "", line 1, in map(m,*l) TypeError: 'int' object is not iterable >>> >>> >>> help(map)\ Help on class map in module builtins: class map(object) | map(func, *iterables) --> map object | | Make an iterator that computes the function using arguments from | each of the iterables. Stops when the shortest iterable is exhausted. | | Methods defined here: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __iter__(self, /) | Implement iter(self). | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | __next__(self, /) | Implement next(self). | | __reduce__(...) | Return state information for pickling. >>> list(map(m,map(m,l))) [0.0, 1.0, 1209.33648530384, 76863.76406798889, 1462494.7346870452, 14369870.171516128, 92954154.28520527, 450613220.96196795, 1768648242.2218032] >>> >>> a Traceback (most recent call last): File "", line 2, in a NameError: name 'a' is not defined >>>