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'
>>> 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]
>>> for x in xs:
... print(x)
a
h
o
j
>>> it = iter(xs)
>>> dir(it)
1: ['__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__']
[About 27 more lines. Double-click to unfold]
>>> next(it)
2: 'a'
>>> next(it)
3: 'h'
>>> next(it)
4: 'o'
>>> next(it)
5: 'j'
>>> next(it)
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
next(it)
StopIteration
>>> it = iter(xs)
>>> next(it)
6: 'a'
>>> next(it)
7: 'h'
>>> for x in it:
... print(x)
o
j
>>> POPISKY = [
... 'HLAVIČKA',
... 'SEKVENCE',
... 'KOMENTÁŘ',
... 'KVALITA ',
... ]
>>> POPISKY[0]
8: 'HLAVIČKA'
>>> POPISKY[3]
9: 'KVALITA '
>>> POPISKY[4]
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
POPISKY[4]
~~~~~~~^^^
IndexError: list index out of range
>>> POPISKY[4:]
10: []
>>> def fn():
... print('START')
... yield 1
... yield 2
... yield 3
... print('KONEC')
>>> fn
11: <function fn at 0x0000025B3E8BB920>
>>> fn()
12: <generator object fn at 0x0000025B3E79BB80>
>>> it = fn()
>>> next(it)
START
13: 1
>>> next(it)
14: 2
>>> next(it)
15: 3
>>> next(it)
KONEC
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
next(it)
StopIteration
>>> for i in fn():
... print(i)
START
1
2
3
KONEC
>>> def sudá_čísla(n=0):
... while True:
... n += 2
... yield n
>>> it = sudá_čísla(10)
>>> next(it)
16: 12
>>> next(it)
17: 14
>>> next(it)
18: 16
>>> next(it)
19: 18
>>> it = sudá_čísla()
>>> next(it)
20: 2
>>> next(it)
21: 4
>>> next(it)
22: 6
>>> def fn(x, haha=[]):
... haha.append(x)
... return haha
>>> fn()
Traceback (most recent call last):
File "<pyshell#39>", line 1, in <module>
fn()
TypeError: fn() missing 1 required positional argument: 'x'
>>> fn(1)
23: [1]
>>> fn(1)
24: [1, 1]
>>> fn(1, [])
25: [1]
>>> fn(1)
26: [1, 1, 1]
>>> def fn(x, haha=[]):
... if haha is None:
... haha = []
... haha.append(x)
... return haha
>>> fn(1, [2, 3])
27: [2, 3, 1]
>>> fn(1, [2, 3])
28: [2, 3, 1]
>>> fn(1)
29: [1]
>>> fn(1)
30: [1, 1]
>>> fn(1)
31: [1, 1, 1]
>>> def fn(x, haha=None):
... if haha is None:
... haha = []
... haha.append(x)
... return haha
>>> fn(1, [2, 3])
32: [2, 3, 1]
>>> fn(1, [2, 3])
33: [2, 3, 1]
>>> fn(1, [2, 3])
34: [2, 3, 1]
>>> fn(1)
35: [1]
>>> fn(1)
36: [1]
>>> fn(1)
37: [1]
>>> fn(1, [2, 3])
38: [2, 3, 1]
>>> fn(1)
39: [1]
>>> def fn(a, b=3):
... print(a**b)
>>> fn(2)
8
>>> fn(2, 4)
16
>>> fn(2)
8
>>> fn(a=2)
8
>>> fn(a=2, b=4)
16
>>> fn(2, b=4)
16
>>> fn(2, 4)
16
>>> def fn(a, *, b=3):
... print(a**b)
>>> fn(2)
8
>>> fn(2, 4)
Traceback (most recent call last):
File "<pyshell#69>", line 1, in <module>
fn(2, 4)
TypeError: fn() takes 1 positional argument but 2 were given
>>> fn(2, b=4)
16
>>> def fn(a, /, b):
... print(a**b)
>>> fn(2, 3)
8
>>> fn(2, b=3)
8
>>> fn(a=2, b=3)
Traceback (most recent call last):
File "<pyshell#74>", line 1, in <module>
fn(a=2, b=3)
TypeError: fn() got some positional-only arguments passed as keyword arguments: 'a'
>>> def fn(a, b, /, c, d='a', *, e='b'):
... print(a, b, c, d, e)
>>> fn()
Traceback (most recent call last):
File "<pyshell#76>", line 1, in <module>
fn()
TypeError: fn() missing 3 required positional arguments: 'a', 'b', and 'c'
>>> fn(1, 2, 3)
1 2 3 a b
>>> fn(1, 2, 3, 4, 5)
Traceback (most recent call last):
File "<pyshell#78>", line 1, in <module>
fn(1, 2, 3, 4, 5)
TypeError: fn() takes from 3 to 4 positional arguments but 5 were given
>>> fn(1, 2, c=3)
1 2 3 a b
>>> fn(1, 2, 3, 4, e=5)
1 2 3 4 5
>>> fn(1, 2, 3, d=4, e=5)
1 2 3 4 5
>>> fn(1, 2, c=3, d=4, e=5)
1 2 3 4 5
>>> fn(1, b=2, c=3, d=4, e=5)
Traceback (most recent call last):
File "<pyshell#83>", line 1, in <module>
fn(1, b=2, c=3, d=4, e=5)
TypeError: fn() got some positional-only arguments passed as keyword arguments: 'b'
>>> def fn(*args, **kwargs):
... print(args)
... print(kwargs)
>>> fn()
()
{}
>>> fn(1, 2, 3)
(1, 2, 3)
{}
>>> fn(1, 2, 3, b=4, a=5)
(1, 2, 3)
{'b': 4, 'a': 5}
>>> x = 3
>>> def fn(y):
... return x + y
>>> fn()
Traceback (most recent call last):
File "<pyshell#90>", line 1, in <module>
fn()
TypeError: fn() missing 1 required positional argument: 'y'
>>> fn(1)
40: 4
>>> def fn(y):
... x = 2
... def fn2(z):
... return x + z
... return fn2(y)
>>> x
41: 3
>>> y
Traceback (most recent call last):
File "<pyshell#94>", line 1, in <module>
y
NameError: name 'y' is not defined
>>> z
Traceback (most recent call last):
File "<pyshell#95>", line 1, in <module>
z
NameError: name 'z' is not defined
>>> fn(1)
42: 3
>>> x
43: 3
>>> def fn(y):
... def fn2(z):
... return y + z
... return fn2
>>> f = fn(5)
>>> f
44: <function fn.<locals>.fn2 at 0x0000025B3E8F85E0>
>>> f(3)
45: 8
>>> f(1)
46: 6
>>> f2 = fn(10)
>>> f(3)
47: 8
>>> f2(3)
48: 13
>>>