Ah, that's because the "python" is actually just using javascript evals.
} else if (mode === 'python') {
if (cmd === 'exit()') { mode = 'sh'; }
else {
try {
// Safe(ish) eval for demo purposes.
// In production, never use eval. Use a JS parser library.
// Mapping JS math to appear somewhat pythonesque
let result = eval(cmd);
if (result !== undefined) output(String(result));
} catch (e) {
output(`Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n${e.name}: ${e.message}`, true);
}
}
} else if (mode === 'python') { if (cmd === 'exit()') { mode = 'sh'; } else { try { // Safe(ish) eval for demo purposes. // In production, never use eval. Use a JS parser library. // Mapping JS math to appear somewhat pythonesque let result = eval(cmd); if (result !== undefined) output(String(result)); } catch (e) { output(`Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n${e.name}: ${e.message}`, true); } }