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

Function atom

18-with-match/lispy/original/lis.py:84–90  ·  view source on GitHub ↗

Numbers become numbers; every other token is a symbol.

(token)

Source from the content-addressed store, hash-verified

82 return atom(token)
83
84def atom(token):
85 "Numbers become numbers; every other token is a symbol."
86 try: return int(token)
87 except ValueError:
88 try: return float(token)
89 except ValueError:
90 return Symbol(token)
91
92################ Interaction: A REPL
93

Callers 1

read_from_tokensFunction · 0.70

Calls 1

SymbolClass · 0.85

Tested by

no test coverage detected