MCPcopy
hub / github.com/fluentpython/example-code-2e / tokenize

Function tokenize

18-with-match/lispy/py3.10/lis.py:31–33  ·  view source on GitHub ↗

Convert a string into a list of tokens.

(s: str)

Source from the content-addressed store, hash-verified

29 return read_from_tokens(tokenize(program))
30
31def tokenize(s: str) -> list[str]:
32 "Convert a string into a list of tokens."
33 return s.replace('(', ' ( ').replace(')', ' ) ').split()
34
35def read_from_tokens(tokens: list[str]) -> Expression:
36 "Read an expression from a sequence of tokens."

Callers 2

parseFunction · 0.70
runFunction · 0.70

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected