From ddbd15c7b5b7606d72a3a379ae81ced0aee88014 Mon Sep 17 00:00:00 2001 From: Joscha Schmiedt <joscha@schmiedt.dev> Date: Mon, 26 Feb 2024 14:55:22 +0100 Subject: [PATCH] Add Container.__getitem__ to allow slicing --- src/linkahead/common/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py index ea537ffe..a7030d95 100644 --- a/src/linkahead/common/models.py +++ b/src/linkahead/common/models.py @@ -3001,6 +3001,10 @@ class Container(list): def __repr__(self): return xml2str(self.to_xml()) + def __getitem__(self, key): + # Construct new Container from list slice + return Container().extend(super().__getitem__(key)) + @staticmethod def from_xml(xml_str): """Creates a Container from the given xml string. -- GitLab