Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A:
- def __init__(self, a):
- self.chislo = a
- def __eq__(self, other):
- return self.chislo == other.chislo
- def __str__(self):
- return f'chisloto e {self.chislo}'
- class B:
- def __init__(self):
- self.obekti = []
- def find(self, obj):
- found = False
- for x in self.obekti:
- if x.chislo == obj:
- found = True
- return found
- def kotka (self, obj):
- self.obekti.append(obj)
- def __add__(self, obj):
- self.obekti.append(obj)
- return self
- def __str__(self):
- temp = ""
- for x in self.obekti:
- temp += str(x) + "\n"
- return temp
- a = A(12)
- b = A(23)
- c = B()
- c.kotka(a)
- c = c + b
- print(a)
- print(c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement