August 2021
Beginner to intermediate
118 pages
1h 29m
English
| Puzzle 12 | Attention Seeker |
| 1: | class Seeker: |
| 2: | def __getattribute__(self, name): |
| 3: | if name not in self.__dict__: |
| 4: | return '<not found>' |
| 5: | return self.__dict__[name] |
| 6: | |
| 7: | |
| 8: | s = Seeker() |
| 9: | print(s.id) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will raise a RecursionError exception.
When you write s.id, Python does an attribute lookup (see puzzle 1, Puzzle 1, ...
Read now
Unlock full access