MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / parse_atom

Function parse_atom

18-with-match/lispy/py3.9/lis.py:49–57  ·  view source on GitHub ↗

Numbers become numbers; every other token is a symbol.

(token: str)

Source from the content-addressed store, hash-verified

47 return parse_atom(token)
48
49def parse_atom(token: str) -> Atom:
50 "Numbers become numbers; every other token is a symbol."
51 try:
52 return int(token)
53 except ValueError:
54 try:
55 return float(token)
56 except ValueError:
57 return Symbol(token)
58
59
60################ Global Environment

Callers 1

read_from_tokensFunction · 0.70

Calls 1

SymbolClass · 0.85

Tested by

no test coverage detected