How do you implement custom container types? #29
Answered
by
lukasmiller3
lukasmiller1
asked this question in
Q&A
-
|
How do you implement custom container types? |
Beta Was this translation helpful? Give feedback.
Answered by
lukasmiller3
Jan 22, 2026
Replies: 1 comment
-
|
A:Implement len for length, getitem for indexing, setitem for assignment, delitem for deletion, contains for membership testing. Optionally implement iter for iteration. This makes objects behave like built-in container types (list, dict, set). |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lukasmiller1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A:Implement len for length, getitem for indexing, setitem for assignment, delitem for deletion, contains for membership testing. Optionally implement iter for iteration. This makes objects behave like built-in container types (list, dict, set).