Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 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 ! >>> xb = b'Ahoj!' >>> for x in xb: ... print(x) 65 104 111 106 33 >>> chr(106) 0: 'j' >>> dir(xs) 1: ['__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] >>> dir(xb) 2: ['__add__', '__bytes__', '__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', 'center', 'count', 'decode', 'endswith', 'expandtabs', 'find', 'fromhex', 'hex', 'index', 'isalnum', 'isalpha', 'isascii', 'isdigit', 'islower', '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 76 more lines. Double-click to unfold] >>> xb.upper() 3: b'AHOJ!' >>> xb = b'a\x07A' >>> xs 4: 'Ahoj!' >>> xb 5: b'a\x07A' >>> for x in xb: ... print(x) 97 7 65 >>> for x in sorted(xb): ... print(x) 7 65 97 >>> for x in reversed(xb): ... print(x) 65 7 97 >>> bytes() 6: b'' >>> bytes(7) 7: b'\x00\x00\x00\x00\x00\x00\x00' >>> bytes([7]) 8: b'\x07' >>> bytes((7,)) 9: b'\x07' >>> bytes({7}) 10: b'\x07' >>> xb = b'\x00\x01\x02\x03\x04\x05\x06' >>> xb 11: b'\x00\x01\x02\x03\x04\x05\x06' >>> type(xb) 12: <class 'bytes'> >>> type(xb[0]) 13: <class 'int'> >>> xb[0] 14: 0 >>> xb[1] 15: 1 >>> [x for x in xb] 16: [0, 1, 2, 3, 4, 5, 6] >>> [x+1 for x in xb] 17: [1, 2, 3, 4, 5, 6, 7] >>> xb[1] 18: 1 >>> xb[1:] 19: b'\x01\x02\x03\x04\x05\x06' >>> xb 20: b'\x00\x01\x02\x03\x04\x05\x06' >>> xxb = bytearray(xb) >>> xxb 21: bytearray(b'\x00\x01\x02\x03\x04\x05\x06') >>> type(xxb) 22: <class 'bytearray'> >>> dir(xxb) 23: ['__add__', '__alloc__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'capitalize', 'center', 'clear', 'copy', 'count', 'decode', 'endswith', 'expandtabs', 'extend', 'find', 'fromhex', 'hex', 'index', 'insert', 'isalnum', 'isalpha', 'isascii', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'pop', 'remove', 'removeprefix', 'removesuffix', 'replace', 'reverse', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'] [About 87 more lines. Double-click to unfold] >>> xxb 24: bytearray(b'\x00\x01\x02\x03\x04\x05\x06') >>> xxb[0] 25: 0 >>> xxb[0] = b'\x13' Traceback (most recent call last): File "<pyshell#36>", line 1, in <module> xxb[0] = b'\x13' ~~~^^^ TypeError: 'bytes' object cannot be interpreted as an integer [About 4 more lines. Double-click to unfold] >>> xxb[0] = 13 >>> xxb 26: bytearray(b'\r\x01\x02\x03\x04\x05\x06') >>> xxb[0] = 255 >>> xxb 27: bytearray(b'\xff\x01\x02\x03\x04\x05\x06') >>> xxb[0] = 256 Traceback (most recent call last): File "<pyshell#41>", line 1, in <module> xxb[0] = 256 ~~~^^^ ValueError: byte must be in range(0, 256) >>> xxb[0] = int.to_bytes(256, 'big') Traceback (most recent call last): File "<pyshell#42>", line 1, in <module> xxb[0] = int.to_bytes(256, 'big') ^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'str' object cannot be interpreted as an integer >>> int.to_bytes(256, 'big') Traceback (most recent call last): File "<pyshell#43>", line 1, in <module> int.to_bytes(256, 'big') TypeError: 'str' object cannot be interpreted as an integer >>> (256).to_bytes(1, 'big') Traceback (most recent call last): File "<pyshell#44>", line 1, in <module> (256).to_bytes(1, 'big') OverflowError: int too big to convert >>> (256).to_bytes(2, 'big') 28: b'\x01\x00' >>> (256).to_bytes(2, 'little') 29: b'\x00\x01' >>> xxb[0] = (256).to_bytes(2, 'big') Traceback (most recent call last): File "<pyshell#47>", line 1, in <module> xxb[0] = (256).to_bytes(2, 'big') ~~~^^^ TypeError: 'bytes' object cannot be interpreted as an integer >>> xxb.insert(0, (256).to_bytes(2, 'big') ) Traceback (most recent call last): File "<pyshell#48>", line 1, in <module> xxb.insert(0, (256).to_bytes(2, 'big') ) TypeError: 'bytes' object cannot be interpreted as an integer >>> (256).to_bytes(2, 'big') + xxb 30: b'\x01\x00\xff\x01\x02\x03\x04\x05\x06' >>> int('01010101', 2) 31: 85 >>> chr(85) 32: 'U' >>> int('10101010', 2) 33: 170 >>> chr(170) 34: 'ยช' >>> hex(int('10101010', 2)) 35: '0xaa' >>> range(8, -1, -1) 36: range(8, -1, -1) >>> [x for x in range(8, -1, -1)] 37: [8, 7, 6, 5, 4, 3, 2, 1, 0] >>>