Skip to content

Add pop() method to list-like model objects to ease their usage #2303

Closed

Description

@jaloren

In a prerun modifier, you may want to remove the last item in the list of keywords. Right now you have to do that via slicing -- it would be cleaner to support the pop in the keyword object. This would require adding the pop method to the ItemList object which in turn is inherited by the keyword object.

Activity

  1. jaloren commented on Jan 18, 2016

    @jaloren
    ContributorAuthor

    This may be used to implement #2302

  2. jaloren commented on Jan 18, 2016

    @jaloren
    ContributorAuthor

    To implement this, do i just need to add the following function to the ItemList class in model/itemlist.py

        def pop(self,item):
            return item[:-1]
  3. pekkaklarck commented on Jan 18, 2016

    @pekkaklarck
    Member

    pop should accept optional index and return the popped item like list.pop does. Easiest implementation would be converting the internal data to a list, popping it, and setting internal data again. Testing best done with unit tests.

    You might also want to check are there other list methods that could be added.

  4. added this to the 3.0.1 milestone on Jan 19, 2016
  5. pekkaklarck commented on Feb 24, 2016

    @pekkaklarck
    Member

    Are you @jaloren interested to implement this? I can easily do it myself too.

  6. jaloren commented on Feb 25, 2016

    @jaloren
    ContributorAuthor

    I am swamped at work right now -- please feel free to do the code submit.

  7. self-assigned this
    on Jun 2, 2016
  8. changed the title [-]Add pop to ItemList for Keyword Object[/-] [+]Add `pop()` method to list-like model objects to ease their usage[/+] on Jun 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions