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

Sections don't support negative keys #27

Closed
drobota opened this issue Oct 23, 2014 · 2 comments
Closed

Sections don't support negative keys #27

drobota opened this issue Oct 23, 2014 · 2 comments

Comments

@drobota
Copy link

drobota commented Oct 23, 2014

I would like to use negatives keys for sections
like :

last_section = page.my_sections[-1]

but due to this code it is impossible

    def __getitem__(self, idx):

        if idx < 0 or idx >= len(self):
            raise IndexError("Sections index (%d) out of range" % idx)
        for i, _ in enumerate(self):
            if i == idx:
                break
        return self
@drobota drobota changed the title Sections don't support negatives keys Sections don't support negative keys Oct 23, 2014
@ncjones
Copy link
Contributor

ncjones commented Oct 28, 2014

The way Holmium conflates sections and section elements is really surprising. I already fixed a bug in this method earlier this year where any index greater than 1 would fail. I think the correct fix for this is to overhaul the structure of the object model so that child items within sections are separate objects.

@drobota
Copy link
Author

drobota commented Nov 9, 2014

Thanks a lot

@drobota drobota closed this as completed Nov 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants