Прикреплённый файл «mro.py»
Загрузка 1 #!/usr/bin/env python3
2 '''
3 '''
4 import re
5
6 Cls, L = {}, {}
7
8 def merge(mros):
9 if not mros:
10 return
11 S = [L.setdefault(c, [c, *merge(Cls[c])]).copy() for c in mros] + [mros]
12 while S:
13 for s in S:
14 if not s: continue
15 e = s[0]
16 if all(e==ss[0] or e not in ss for ss in S):
17 yield e
18 for ss in S:
19 if ss and ss[0] == e:
20 del ss[0]
21 S = list(filter(len, S))
22 break
23 else:
24 raise TypeError
25
26 reClass = re.compile(r"class\s+(\w+)\s*(?:\((.*)\))?\s*:")
27 s = input().rstrip()
28 while s:
29 res = reClass.match(s)
30 if res:
31 Nam, Par = res.groups()
32 Cls[Nam] = [c.strip() for c in Par.split(",")] if Par else []
33 try:
34 L[Nam] = [Nam, *merge(Cls[Nam])]
35 except TypeError:
36 print("No")
37 break
38 s = input().rstrip()
39 else:
40 print("Yes")
Прикреплённые файлы
Для ссылки на прикреплённый файл в тексте страницы напишите attachment:имяфайла, как показано ниже в списке файлов. Не используйте URL из ссылки «[получить]», так как он чисто внутренний и может измениться.Вам нельзя прикреплять файлы к этой странице.
