Registry Mirror
搜索
Skip to content
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Files
Expand file tree
master
Breadcrumbs
python
/
bingoaddable.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
26 lines (21 loc) · 868 Bytes
master
Breadcrumbs
python
/
bingoaddable.py
Copy path
Top
File metadata and controls
Code
Blame
26 lines (21 loc) · 868 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from typing import Any, Self
from bingo import BingoCage
from tombola import Tombola
class AddableBingoCage(BingoCage):
"""A BingoCage supporting + and += with other Tombolas or iterables."""
def __add__(self, other: Any) -> 'AddableBingoCage':
if isinstance(other, Tombola):
return AddableBingoCage(self.inspect() + other.inspect())
return NotImplemented
def __iadd__(self, other: Any) -> Self:
if isinstance(other, Tombola):
other_iterable = other.inspect()
else:
try:
other_iterable = iter(other)
except TypeError:
self_cls = type(self).__name__
msg = "right operand in += must be {!r} or an iterable"
raise TypeError(msg.format(self_cls)) from None
self.load(other_iterable)
return self
You can’t perform that action at this time.