File: automaton_pop.rst

package info (click to toggle)
python-pyahocorasick 1.4.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 748 kB
  • sloc: ansic: 4,554; python: 2,823; sh: 312; makefile: 242
file content (29 lines) | stat: -rw-r--r-- 708 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
pop(word)
--------------------------------------------------------------------------------

Remove given word from a trie and return associated values. Raise a ``KeyError``
if the word was not found.

Examples
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

    >>> import ahocorasick
    >>> A = ahocorasick.Automaton()
    >>> A.add_word("cat", 1)
    True
    >>> A.add_word("dog", 2)
    True
    >>> A.pop("elephant")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    KeyError
    >>> A.pop("cat")
    1
    >>> A.pop("dog")
    2
    >>> A.pop("cat")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    KeyError