Python 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. DreamPie 1.2.1 >>> def fn(): ... ... >>> fn 0: <function fn at 0x0000020FDA2B8400> >>> dir(...) 1: ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] >>> type(...) 2: <class 'ellipsis'> >>> fn() >>> print(fn()) None >>> dir(fn) 3: ['__annotations__', '__builtins__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__getstate__', '__globals__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__type_params__'] >>> fn.__call__ 4: <method-wrapper '__call__' of function object at 0x0000020FDA2B8400> >>> fn.__call__() >>> fn() >>> def fn(): ... print('Ahoj!') >>> fn() Ahoj! >>> fn.__call__() Ahoj! >>> fn.baf = 666 >>> fn.baf 5: 666 >>> def fn(x, y): ... print(x) ... print(y) >>> fn() Traceback (most recent call last): File "<pyshell#16>", line 1, in <module> fn() ~~^^ TypeError: fn() missing 2 required positional arguments: 'x' and 'y' >>> fn(1, 2) 1 2 >>> fn(x=1, y=2) 1 2 >>> fn(1, y=2) 1 2 >>> #fn(x=1, 2) >>> fn(a=1, b=2) Traceback (most recent call last): File "<pyshell#21>", line 1, in <module> fn(a=1, b=2) ~~^^^^^^^^^^ TypeError: fn() got an unexpected keyword argument 'a' >>> def fn(x, y, z=333): ... print(x) ... print(y) ... print(z) >>> fn() Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> fn() ~~^^ TypeError: fn() missing 2 required positional arguments: 'x' and 'y' >>> fn(1, 2) 1 2 333 >>> fn(1, 2, 3) 1 2 3 >>> fn(1, 2, z=3) 1 2 3 >>> def fn(x, *y, z=333): ... print(x) ... print(y) ... print(z) >>> fn() Traceback (most recent call last): File "<pyshell#28>", line 1, in <module> fn() ~~^^ TypeError: fn() missing 1 required positional argument: 'x' >>> fn(1) 1 () 333 >>> fn(1, 2) 1 (2,) 333 >>> fn(1, 2, 3) 1 (2, 3) 333 >>> fn(1, 2, 3, 4) 1 (2, 3, 4) 333 >>> fn(1, 2, 3, 4, 5) 1 (2, 3, 4, 5) 333 >>> fn(1, 2, 3, 4, 5, z=6) 1 (2, 3, 4, 5) 6 >>> def fn(x, *y, z=333, **u): ... print(x) ... print(y) ... print(z) ... print(u) >>> fn() Traceback (most recent call last): File "<pyshell#36>", line 1, in <module> fn() ~~^^ TypeError: fn() missing 1 required positional argument: 'x' >>> fn(1) 1 () 333 {} >>> fn(1, a=1, b=2) 1 () 333 {'a': 1, 'b': 2} >>> fn(1, 2, 3, a=1, b=2) 1 (2, 3) 333 {'a': 1, 'b': 2} >>> fn(1, 2, 3, a=1, b=2, z=3) 1 (2, 3) 3 {'a': 1, 'b': 2} >>> fn(1, 2, 3, b=1, z=2, a=3) 1 (2, 3) 2 {'b': 1, 'a': 3} >>> def fn(*x, **y): ... print(x) ... print(y) >>> fn() () {} >>> fn(a=1) () {'a': 1} >>> fn(a=1, b=2) () {'a': 1, 'b': 2} >>> fn(3, a=1, b=2) (3,) {'a': 1, 'b': 2} >>> fn(3, 4, a=1, b=2) (3, 4) {'a': 1, 'b': 2} >>> def fn(*args, **kwargs): ... print(args) ... print(kwargs) >>> fn(3, 4, a=1, b=2) (3, 4) {'a': 1, 'b': 2} >>> def fn(x, y, z): ... print(x, y, z) >>> fn() Traceback (most recent call last): File "<pyshell#51>", line 1, in <module> fn() ~~^^ TypeError: fn() missing 3 required positional arguments: 'x', 'y', and 'z' >>> fn(1, 2, 3) 1 2 3 >>> fn(1, y=2, z=3) 1 2 3 >>> def fn(x, /, y, z): ... print(x, y, z) >>> fn(1, 2, 3) 1 2 3 >>> fn(1, y=2, z=3) 1 2 3 >>> fn(1, 2, z=3) 1 2 3 >>> fn(1, 2, 3) 1 2 3 >>> fn(x=1, y=2, z=3) Traceback (most recent call last): File "<pyshell#59>", line 1, in <module> fn(x=1, y=2, z=3) ~~^^^^^^^^^^^^^^^ TypeError: fn() got some positional-only arguments passed as keyword arguments: 'x' >>> def fn(x, y, z): ... print(x, y, z) >>> fn(x=1, y=2, z=3) 1 2 3 >>> def fn(x, y, z=1, u=2): ... print(x, y, z, u) >>> fn() Traceback (most recent call last): File "<pyshell#63>", line 1, in <module> fn() ~~^^ TypeError: fn() missing 2 required positional arguments: 'x' and 'y' >>> fn(5, 6) 5 6 1 2 >>> fn(5, 6, 7, 8) 5 6 7 8 >>> fn(5, 6, z=7, u=8) 5 6 7 8 >>> def fn(x, y, z=1, *, u=2): ... print(x, y, z, u) >>> fn(5, 6, 7, 8) Traceback (most recent call last): File "<pyshell#68>", line 1, in <module> fn(5, 6, 7, 8) ~~^^^^^^^^^^^^ TypeError: fn() takes from 2 to 3 positional arguments but 4 were given >>> fn(5, 6, 7, u=8) 5 6 7 8 >>> fn(5, 6, z=7, u=8) 5 6 7 8 >>> fn(5, y=6, z=7, u=8) 5 6 7 8 >>> fn(x=5, y=6, z=7, u=8) 5 6 7 8 >>> def fn(x, y, /, *, z=1, u=2): ... print(x, y, z, u) >>> fn() Traceback (most recent call last): File "<pyshell#74>", line 1, in <module> fn() ~~^^ TypeError: fn() missing 2 required positional arguments: 'x' and 'y' >>> fn(4, 5) 4 5 1 2 >>> fn(4, 5, 6, 7) Traceback (most recent call last): File "<pyshell#76>", line 1, in <module> fn(4, 5, 6, 7) ~~^^^^^^^^^^^^ TypeError: fn() takes 2 positional arguments but 4 were given >>> fn(4, 5, 6, u=7) Traceback (most recent call last): File "<pyshell#77>", line 1, in <module> fn(4, 5, 6, u=7) ~~^^^^^^^^^^^^^^ TypeError: fn() takes 2 positional arguments but 3 positional arguments (and 1 keyword-only argument) were given >>> fn(4, 5, z=6, u=7) 4 5 6 7 >>> fn(4, 5, u=6, z=7) 4 5 7 6 >>> x = [3] >>> def f(y): ... y = 2 * y >>> f(x) >>> x 6: [3] >>> def f(y): ... print(y) ... y = 2 * y ... print(y) >>> x 7: [3] >>> f(x) [3] [3, 3] >>> x 8: [3] >>> def f(y): ... print(y) ... y[-1] = 2 * y ... print(y) >>> f(x) [3] [[3, 3]] >>> x 9: [[3, 3]] >>> def f(x, xs=[]): ... xs.append(x) ... print(xs) >>> f(1, []) [1] >>> f(1, []) [1] >>> f(1, [2, 3]) [2, 3, 1] >>> f(1, [2, 3]) [2, 3, 1] >>> f(1) [1] >>> f(1, [2, 3]) [2, 3, 1] >>> f(1) [1, 1] >>> f(1) [1, 1, 1] >>> f(1) [1, 1, 1, 1] >>> f(1) [1, 1, 1, 1, 1] >>> f(1, [2, 3]) [2, 3, 1] >>> f(1, []) [1] >>> f(1) [1, 1, 1, 1, 1, 1] >>> 1 or 'abc' 10: 1 >>> False or 'abc' 11: 'abc' >>> False and 'abc' 12: False >>> 1 and 'abc' 13: 'abc' >>> 1 and '' 14: '' >>> bool(1 and '') 15: False >>> 'abc' and 1 16: 1 >>> '' and 1 17: '' >>> bool('') 18: False >>> '' or 1 19: 1 >>> bool(1) 20: True >>> bool('') 21: False >>> bool(()) 22: False >>> bool([]) 23: False >>> bool({}) 24: False >>> bool(set()) 25: False >>> bool(frozenset()) 26: False >>> bool(print) 27: True >>> f 28: <function f at 0x0000020FDC523060> >>> bool(f) 29: True >>> class T: ... ... >>> bool(T) 30: True >>> bool(0) 31: False >>> bool(0.0) 32: False >>> bool(4) 33: True >>> bool(0j) 34: False >>>