Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support slicing in Containers #453

Open
achilleas-k opened this issue Mar 27, 2020 · 0 comments
Open

Support slicing in Containers #453

achilleas-k opened this issue Mar 27, 2020 · 0 comments

Comments

@achilleas-k
Copy link
Member

nixpy/nixio/container.py

Lines 38 to 47 in 1eedabf

def __getitem__(self, item):
if isinstance(item, int):
if item < 0:
item = len(self) + item
if item < 0 or item >= len(self):
raise IndexError("Index out of bounds: {}".format(item))
item = self._backend.get_by_pos(item)
else:
item = self._backend.get_by_id_or_name(item)
return self._inst_item(item)

If it's not an int, it assumes it's a string to search for name. Slices should also be supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant