The code
module provides facilities to implement
read-eval-print loops in Python. Two classes and convenience
functions are included which can be used to build applications which
provide an interactive interpreter prompt.
'__name__'
set to '__console__'
and key '__doc__'
set to None
.
sys.ps1
and sys.ps2
, and
input buffering.
source is the source string; filename is the optional
filename from which source was read, defaulting to '<input>'
;
and symbol is the optional grammar start symbol, which should
be either 'single'
(the default) or 'eval'
.
Returns a code object (the same as compile(source,
filename, symbol)
) if the command is complete and
valid; None
if the command is incomplete; raises
SyntaxError if the command is complete and contains a
syntax error, or raises OverflowError if the command
includes a numeric constant which exceeds the range of the
appropriate numeric type.
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant