def pop( self, *args, **kwargs):
if not args:<EOL><INDENT>args = [-<NUM_LIT:1>]<EOL><DEDENT>for k,v in kwargs.items():<EOL><INDENT>if k == '<STR_LIT:default>':<EOL><INDENT>args = (args[<NUM_LIT:0>], v)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>" % k)<EOL><DEDENT><DEDENT>if (isinstance(args[<NUM_LIT:0>], int) or<EOL>len(args) == <NUM_LIT:1> or<EOL>args[<NUM_LIT:0>] in self):<EOL><INDENT>index = args[<NUM_LIT:0>]<EOL>ret = self[index]<EOL>del self[index]<EOL>return ret<EOL><DEDENT>else:<EOL><INDENT>defaultvalue = args[<NUM_LIT:1>]<EOL>return defaultvalue<EOL><DEDENT>
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed tokens. If passed
a non-integer argument (most likely a string), it will use ``dict``
semantics and pop the corresponding value from any defined results
names. A second default return value argument is supported, just as in
``dict.pop()``.

Example::

    def remove_first(tokens):
        tokens.pop(0)
    print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
    print(OneOrMore(Word(nums)).addParseAction(remove_first).parseString("0 123 321")) # -> ['123', '321']

    label = Word(alphas)
    patt = label("LABEL") + OneOrMore(Word(nums))
    print(patt.parseString("AAB 123 321").dump())

    # Use pop() in a parse action to remove named result (note that corresponding value is not
    # removed from list form of results)
    def remove_LABEL(tokens):
        tokens.pop("LABEL")
        return tokens
    patt.addParseAction(remove_LABEL)
    print(patt.parseString("AAB 123 321").dump())

prints::

    ['AAB', '123', '321']
    - LABEL: AAB

    ['AAB', '123', '321']