Skip to content
Snippets Groups Projects
Commit ddbd15c7 authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

Add Container.__getitem__ to allow slicing

parent 8ca6abe5
No related branches found
No related tags found
2 merge requests!143Release 0.15.0,!131Resolve "EXTERN: Slicing a Container returns a List, not a Container"
Pipeline #47851 failed
...@@ -3001,6 +3001,10 @@ class Container(list): ...@@ -3001,6 +3001,10 @@ class Container(list):
def __repr__(self): def __repr__(self):
return xml2str(self.to_xml()) return xml2str(self.to_xml())
def __getitem__(self, key):
# Construct new Container from list slice
return Container().extend(super().__getitem__(key))
@staticmethod @staticmethod
def from_xml(xml_str): def from_xml(xml_str):
"""Creates a Container from the given xml string. """Creates a Container from the given xml string.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment