A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-May/015041.html below:

[Python-Dev] Scanner

[Python-Dev] ScannerPaul Prescod paulp@ActiveState.com
Sat, 26 May 2001 08:02:08 -0700
What ever happened to the sre Scanner? It seemed like a good idea but it
was not documented and it doesn't work for me. Is it just a case of
nobody got around to the documentation or have we decided against it?

Here's the code that doesn't work for me:

from sre import Scanner

scanner = Scanner([
    (r"[a-zA-Z_]\w*", None),
    (r"\d+\.\d*", None),
    (r"\d+", None),
    (r"=|\+|-|\*|/", None),
    (r"\s+", None),
    ])

tokens, tail = scanner.scan("sum = 3*foo + 312.50 + bar")

Traceback (most recent call last):
  File "junk.py", line 11, in ?
    tokens, tail = scanner.scan("sum = 3*foo + 312.50 + bar")
  File "c:\program files\python21\lib\sre.py", line 254, in scan
    action = self.lexicon[m.lastindex][1]
TypeError: sequence index must be integer

m.lastindex is None
-- 
Take a recipe. Leave a recipe.  
Python Cookbook!  http://www.ActiveState.com/pythoncookbook



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4