Python 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. DreamPie 1.2.1 >>> xs = 'ahoj' ... for x in xs: ... print(x) a h o j >>> dir(xs) 0: ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'] [About 80 more lines. Double-click to unfold] >>> it = iter(xs) >>> type(it) 1: <class 'str_ascii_iterator'> >>> dir(it) 2: ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__length_hint__', '__lt__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__'] >>> next(it) 3: 'a' >>> next(it) 4: 'h' >>> for x in it: ... print(x) o j >>> next(it) Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> next(it) ~~~~^^^^ StopIteration >>> def fn(): ... print('1') ... yield 1 ... print('2') ... yield 2 ... print('3') >>> fn 5: <function fn at 0x0000012AC4DD6B60> >>> fn() 6: <generator object fn at 0x0000012AC3101FC0> >>> it = fn() >>> dir(it) 7: ['__class__', '__class_getitem__', '__del__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__name__', '__ne__', '__new__', '__next__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'gi_code', 'gi_frame', 'gi_running', 'gi_suspended', 'gi_yieldfrom', 'send', 'throw'] >>> type(it) 8: <class 'generator'> >>> next(it) 1 9: 1 >>> next(it) 2 10: 2 >>> next(it) 3 Traceback (most recent call last): File "<pyshell#17>", line 1, in <module> next(it) ~~~~^^^^ StopIteration >>> def fn(): ... print(1) ... yield 'A' ... print(2) ... yield 'B' ... print(3) >>> it = fn() >>> next(it) 1 11: 'A' >>> next(it) 2 12: 'B' >>> next(it) 3 Traceback (most recent call last): File "<pyshell#22>", line 1, in <module> next(it) ~~~~^^^^ StopIteration >>> def fn(): ... print(1) ... yield 'A' ... print(2) ... return 'Baf!' ... yield 'B' ... print(3) >>> it = fn() >>> next(it) 1 13: 'A' >>> next(it) 2 Traceback (most recent call last): File "<pyshell#26>", line 1, in <module> next(it) ~~~~^^^^ StopIteration: Baf! >>> def fn(): ... yield 'A' ... yield 'B' ... yield 'C' >>> for x in fn(): ... print(x) A B C >>> for x in fn: ... print(x) Traceback (most recent call last): File "<pyshell#29>", line 1, in <module> for x in fn: ^^ TypeError: 'function' object is not iterable >>> dir(fn) 14: ['__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__'] [About 37 more lines. Double-click to unfold] >>> def moje_funkce(): ... print('moje funkce') >>> moje_funkce() moje funkce >>> def dekorátor(funkce): ... def _dekorátor(): ... print('START') ... return funkce() ... return _dekorátor >>> @dekorátor ... def moje_funkce(): ... print('moje funkce') >>> moje_funkce() START moje funkce >>> def moje_funkce(): ... print('moje funkce') >>> moje_funkce 15: <function moje_funkce at 0x0000012AC4DDD6C0> >>> dir(moje_funkce) 16: ['__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__'] [About 37 more lines. Double-click to unfold] >>> moje_funkce.__name__ 17: 'moje_funkce' >>> @dekorátor ... def moje_funkce(): ... print('moje funkce') >>> moje_funkce.__name__ 18: '_dekorátor' >>> moje_funkce 19: <function dekorátor.<locals>._dekorátor at 0x0000012AC4DF82C0> >>> def dekorátor(funkce): ... def _dekorátor(): ... print('START') ... ret = funkce() ... print('END') ... return ret ... _dekorátor.__name__ = funkce.__name__ ... return _dekorátor >>> @dekorátor ... def moje_funkce(): ... print('moje funkce') >>> moje_funkce.__name__ 20: 'moje_funkce' >>> def _omez_hodnoty(funkce): ... def __omez_hodnoty(xs): ... ret = funkce( [x for x in xs] ) ... return ret ... return __omez_hodnoty >>> @_omez_hodnoty ... def zpracuj_hodnoty_1(xs): ... return [x**2 for x in xs] >>> zpracuj_hodnoty_1([1, 3, 11, 4, 7, 14, 5]) 21: [1, 9, 121, 16, 49, 196, 25] >>> def _omez_hodnoty(funkce): ... def __omez_hodnoty(xs): ... print('Baf!') ... ret = funkce( [x for x in xs] ) ... return ret ... return __omez_hodnoty >>> @_omez_hodnoty ... def zpracuj_hodnoty_1(xs): ... return [x**2 for x in xs] >>> zpracuj_hodnoty_1([1, 3, 11, 4, 7, 14, 5]) Baf! 22: [1, 9, 121, 16, 49, 196, 25] >>> def omez_hodnoty(maximum): ... def _omez_hodnoty(funkce): ... def __omez_hodnoty(xs): ... print('Baf!') ... ret = funkce( [x for x in xs if x <= maximum] ) ... return ret ... return __omez_hodnoty ... return _omez_hodnoty >>> @omez_hodnoty(9) ... def zpracuj_hodnoty_2(xs): ... return [x**2 for x in xs] >>> zpracuj_hodnoty_1([1, 3, 11, 4, 7, 14, 5]) Baf! 23: [1, 9, 121, 16, 49, 196, 25] >>> zpracuj_hodnoty_2([1, 3, 11, 4, 7, 14, 5]) Baf! 24: [1, 9, 16, 49, 25] >>> for x in 'abc': ... print(x) a b c >>> for x in zip('abc', 'ABC'): ... print(x) ('a', 'A') ('b', 'B') ('c', 'C') >>> for x in zip('abcdef', 'ABC'): ... print(x) ('a', 'A') ('b', 'B') ('c', 'C') >>> for x in zip('abcdef', 'ABC', '12345'): ... print(x) ('a', 'A', '1') ('b', 'B', '2') ('c', 'C', '3') >>> for x,y,z in zip('abcdef', 'ABC', '12345'): ... print(x, y, z) a A 1 b B 2 c C 3 >>>