Github Experimental restricted subset of Python for safe evaluation by @readevalprint
7.657850000015287 ms
CallTooDeep('Sorry, stack is to large. The MAX_CALL_DEPTH is 32.  at line: 5, column:8')

Previous Evaluation

def f():
    try:
        pass
    finally:
        return 1

def g():
    try:
        pass
    finally:
        try:
            return 2
        finally:
            pass

def h():
    try:
        pass
    finally:
        try:
            pass
        finally:
            for x in range(10):
                return 3

f()
g()
h()
FeatureNotAvailable('Sorry, Pass is not available in this evaluator')
Link time elapsed: 0.318 ms
b = []
i = 100
while i > 0:
	b = [b, [b]]
	i = i - 1
b
ScopeTooLarge('Scope has used too much memory: 25116 > 20000.0')
Link time elapsed: 107.407 ms
b = []
i = 10
while i > 0:
	b = [b, [b]]
	i = i - 1
b
[None,
 None,
 None,
 [[[[[[[[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]],
        [[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]]]],
       [[[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]],
         [[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]]]]]],
      [[[[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]],
         [[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]]]],
        [[[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]],
          [[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]]]]]]]],
     [[[[[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]],
         [[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]]]],
        [[[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]],
          [[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]]]]]],
       [[[[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]], [[[], [[]]]]]]],
          [[[[[], [[]]], [[[], [[]]]]], [[[[], [[]]]…
Link time elapsed: 324.471 ms
def f(n=1000):
	if n > 0:
		return f(n-1)
	else:	
		0

f()
CallTooDeep('Sorry, stack is to large. The MAX_CALL_DEPTH is 32.')
Link time elapsed: 15.151 ms
a = ["hi", "world"]
" ".join(a)

def test( flag_input ):
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

test()
TypeError("_func() missing a required argument: 'flag_input'")
Link time elapsed: 63.325 ms
a = ["hi", "world"]
" ".join(a)
[None, 'hi world']
Link time elapsed: 1.127 ms
a = ["hi", "world"]
" ".join(a)

def another():
	#print(10)
	return 10
	
def test( flag_input ):
	another()
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

test('23424')
[None, 'hi world', None, None, 1]
Link time elapsed: 2.338 ms
a = ["hi", "world"]
" ".join(a)

def another():
	print(10)
	return 10
	
def test( flag_input ):
	another()
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

test('23424')
NameNotDefined("'print' is not defined")
Link time elapsed: 30.626 ms
a = ["hi", "world"]
" ".join(a)

def another():
	return 10
	
def test( flag_input ):
	another()
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

test('23424')
[None, 'hi world', None, None, 1]
Link time elapsed: 3.096 ms
a = ["hi", "world"]
" ".join(a)

def test( flag_input ):
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

test('23424')
[None, 'hi world', None, 1]
Link time elapsed: 1.971 ms
10000000000**100000000000000000
SnekArithmeticError("Sorry! I don't want to evaluate 10000000000 ** 100000000000000000")
Link time elapsed: 0.558 ms
f"{1:200f}"
SnekRuntimeError('Sorry, this format width is too long.')
Link time elapsed: 1.105 ms
f"{1:.100f}"
['1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000']
Link time elapsed: 1.835 ms
 f"{1:.100f}"
IndentationError('unexpected indent', ('<unknown>', 1, 1, ' f"{1:.100f}"\n'))
Link time elapsed: 0.106 ms
import os
SnekImportError("'os' at line: 1, column:0")
Link time elapsed: 0.813 ms
import sys
SnekImportError("'sys' at line: 1, column:0")
Link time elapsed: 0.287 ms
def f(n=1000):
	pass

f.__code__
FeatureNotAvailable('Sorry, access to this attribute is not available. (__code__) at line: 4, column:0')
Link time elapsed: 0.751 ms
def f(n=1000):
	pass

dir(f)
NameNotDefined("'dir' is not defined at line: 4, column:0")
Link time elapsed: 0.807 ms
def f(n=1000):
	pass

vars(f)
NameNotDefined("'vars' is not defined at line: 4, column:0")
Link time elapsed: 1.761 ms
def f(n=1000):
	pass

print(vars(f))
NameNotDefined("'print' is not defined at line: 4, column:0")
Link time elapsed: 0.832 ms
def f(n=1000):

print(vars(f))
IndentationError('expected an indented block', ('<unknown>', 3, 5, 'print(vars(f))\n'))
Link time elapsed: 0.221 ms
def f(n=1000)
	if n > 0:
		return f(n-1)
	else:	
		0

f()
SyntaxError('invalid syntax', ('<unknown>', 1, 14, 'def f(n=1000)\n'))
Link time elapsed: 0.153 ms
def f():
	return f()
[None]
Link time elapsed: 1.574 ms
def f():
	f()
[None]
Link time elapsed: 1.125 ms
num=0
out = []
while num < 20:
    if num % 3 == 0:
         out.append("Fizz")
    if num % 5 == 0:
        out.append("Buzz")
    if num % 5 != 0 and num % 3 != 0:
        out.append(str(num))
    num = num + 1
out
[None,
 None,
 None,
 ['Fizz',
  'Buzz',
  '1',
  '2',
  'Fizz',
  '4',
  'Buzz',
  'Fizz',
  '7',
  '8',
  'Fizz',
  'Buzz',
  '11',
  'Fizz',
  '13',
  '14',
  'Fizz',
  'Buzz',
  '16',
  '17',
  'Fizz',
  '19']]
Link time elapsed: 29.204 ms
def f():
    try:
        pass
    finally:
        return

def g():
    try:
        pass
    finally:
        try:
            return
        finally:
            pass

def h():
    try:
        pass
    finally:
        try:
            pass
        finally:
            for x in range(10):
                return

f()
g()
h()
FeatureNotAvailable('Sorry, Pass is not available in this evaluator at line: 14, column:12')
Link time elapsed: 14.306 ms
def test( flag_input ):
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

test.func_name
SnekAttributeError("'function' object has no attribute 'func_name' at line: 8, column:0")
Link time elapsed: 0.956 ms
def test( flag_input ):
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

test.func_dict
SnekAttributeError("'function' object has no attribute 'func_dict' at line: 8, column:0")
Link time elapsed: 0.735 ms
def test( flag_input ):
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

test.func_code
SnekAttributeError("'function' object has no attribute 'func_code' at line: 8, column:0")
Link time elapsed: 0.883 ms
def test( flag_input ):
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

test()
TypeError("_func() missing a required argument: 'flag_input'")
Link time elapsed: 1.007 ms
def test( flag_input ):
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

dir(test)
NameNotDefined("'dir' is not defined at line: 8, column:0")
Link time elapsed: 1.978 ms
def test( flag_input ):
	if flag_input == 12345:
		"Success!"
	else:
		"Failure !"
	return 1

print dir(test)
SyntaxError('invalid syntax', ('<unknown>', 8, 9, 'print dir(test)\n'))
Link time elapsed: 0.152 ms
def test( flag_input ):
	if flag_input == 12345:
		"Success!"
	else:
        "Failure !"
   return 1

print dir(test)
TabError('inconsistent use of tabs and spaces in indentation', ('<unknown>', 5, 20, '        "Failure !"\n'))
Link time elapsed: 0.196 ms
def test( flag_input ):
   if flag_input == 12345:
        print "Success!"
   else:
        print "Failure !"
   return 1

print dir(test)
SyntaxError('invalid syntax', ('<unknown>', 3, 24, '        print "Success!"\n'))
Link time elapsed: 0.129 ms
x
NameNotDefined("'x' is not defined at line: 1, column:0")
Link time elapsed: 0.501 ms
10**10**10
SnekArithmeticError("Sorry! I don't want to evaluate 10 ** 10000000000 at line: 1, column:0")
Link time elapsed: 1.475 ms
10**1000
[10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000…
Link time elapsed: 0.409 ms
10**100
[10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
Link time elapsed: 0.341 ms
0xa
[10]
Link time elapsed: 0.250 ms
print('abcd')
NameNotDefined("'print' is not defined at line: 1, column:0")
Link time elapsed: 0.211 ms
print(0xa)
NameNotDefined("'print' is not defined at line: 1, column:0")
Link time elapsed: 0.213 ms
import math
math.pi
SnekImportError("'math' at line: 1, column:0")
Link time elapsed: 0.191 ms
1/0
SnekArithmeticError('division by zero at line: 1, column:0')
Link time elapsed: 0.272 ms
1/"abc"
SnekTypeError("unsupported operand type(s) for /: 'int' and 'str' at line: 1, column:0")
Link time elapsed: 0.240 ms
a/"abc"
NameNotDefined("'a' is not defined at line: 1, column:0")
Link time elapsed: 0.243 ms
input
NameNotDefined("'input' is not defined at line: 1, column:0")
Link time elapsed: 0.179 ms
del(print)
FeatureNotAvailable('Sorry, cannot delete Name at line: 1, column:4')
Link time elapsed: 0.473 ms
dir
NameNotDefined("'dir' is not defined at line: 1, column:0")
Link time elapsed: 0.176 ms
[]
Link time elapsed: 0.234 ms
quit()
NameNotDefined("'quit' is not defined at line: 1, column:0")
Link time elapsed: 0.220 ms
a=42
b=f'class of {a}'
c=3
d=4
a
b
c
d
[None, None, None, None, 42, 'class of 42', 3, 4]
Link time elapsed: 0.752 ms
a=42
b=f'class of {a}'
c=3
d=4
[None, None, None, None]
Link time elapsed: 0.610 ms
a=42
b=f'class of {a}'
[None, None]
Link time elapsed: 0.913 ms
a=42
f'class of {a}'
123
[None, 'class of 42', 123]
Link time elapsed: 1.041 ms
a=42
f'class of {a}'
return 123
Return(123)
Link time elapsed: 5.589 ms
a=42
f'class of {a}'
[None, 'class of 42']
Link time elapsed: 1.089 ms
a=42
f'class of {a} is {a.__class__}'
FeatureNotAvailable('Sorry, access to this attribute is not available. (__class__) at line: 2, column:19')
Link time elapsed: 1.087 ms
f'class of {42} is {42.__class__}'
SyntaxError('invalid syntax', ('<fstring>', 1, 13, '(42.__class__)'))
Link time elapsed: 0.127 ms
'class of {0} is {0.__class__}'.format(42)
FeatureNotAvailable('Sorry, this method is not available. (str.format) at line: 1, column:0')
Link time elapsed: 0.762 ms
def f():
    try:
        z=0
    finally:
        return 10

def g():
    try:
        z=0
    finally:
        try:
            return 20
        finally:
            z=0

def h():
    try:
        z=0
    finally:
        try:
            z=0
        finally:
            for x in [0,1,2,3,4,5,6,7,8,9]:
                return 30

f()
g()
h()
[None, None, None, 10, 20, 30]
Link time elapsed: 3.183 ms
def f():
    try:
        z=0
    finally:
        return 1

def g():
    try:
        z=0
    finally:
        try:
            return 2
        finally:
            z=0

def h():
    try:
        z=0
    finally:
        try:
            z=0
        finally:
            for x in [0,1,2,3,4,5,6,7,8,9]:
                return 3

f()
g()
h()
[None, None, None, 1, 2, 3]
Link time elapsed: 2.671 ms
def f():
    try:
        z=0
    finally:
        return 1

def g():
    try:
        z=0
    finally:
        try:
            return 2
        finally:
            z=0

def h():
    try:
        z=0
    finally:
        try:
            z=0
        finally:
            for x in range(10):
                return 3

f()
g()
h()
NameNotDefined("'range' is not defined at line: 23, column:21")
Link time elapsed: 8.367 ms
def bar():
    try:
        1 / 0
    finally:
        break
            
bar()
FeatureNotAvailable('Sorry, Break is not available in this evaluator at line: 5, column:8')
Link time elapsed: 0.734 ms
def bar():
    while True:
        try:
            1 / 0
        finally:
            break
            
bar()
FeatureNotAvailable('Sorry, Break is not available in this evaluator at line: 6, column:12')
Link time elapsed: 1.320 ms
return "hello"
Return('hello')
Link time elapsed: 0.544 ms
#https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
return
FeatureNotAvailable('Sorry, NoneType is not available in this evaluator at line: None, column:None')
Link time elapsed: 0.205 ms
#https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
import numpy
SnekImportError("'numpy' at line: 2, column:0")
Link time elapsed: 0.271 ms
#https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
import ast
SnekImportError("'ast' at line: 2, column:0")
Link time elapsed: 0.530 ms
#https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
[
    c for c in 
    ().__class__.__bases__[0].__subclasses__() 
    if c.__name__ == "Quitter"
][0](0)()
FeatureNotAvailable('Sorry, access to this attribute is not available. (__subclasses__) at line: 4, column:4')
Link time elapsed: 0.696 ms
#https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
lambda n: [c for c in ALL_CLASSES if c.__name__ == n][0]
FeatureNotAvailable('Sorry, Lambda is not available in this evaluator at line: 2, column:0')
Link time elapsed: 0.362 ms
#https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
eval("__import__('os').system('clear')", {'__builtins__':{}})
NameNotDefined("'eval' is not defined at line: 2, column:0")
Link time elapsed: 0.220 ms
#https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
eval("os.system('clear')", {})
NameNotDefined("'eval' is not defined at line: 2, column:0")
Link time elapsed: 0.277 ms
continue
FeatureNotAvailable('Sorry, Continue is not available in this evaluator at line: 1, column:0')
Link time elapsed: 0.314 ms
break
FeatureNotAvailable('Sorry, Break is not available in this evaluator at line: 1, column:0')
Link time elapsed: 0.164 ms
from "/etc" import *
SyntaxError('invalid syntax', ('<unknown>', 1, 11, 'from "/etc" import *\n'))
Link time elapsed: 0.201 ms
from . import *
KeyError(None)
Link time elapsed: 0.267 ms
import boto
SnekImportError("'boto' at line: 1, column:0")
Link time elapsed: 0.698 ms
import bs4
SnekImportError("'bs4' at line: 1, column:0")
Link time elapsed: 0.173 ms
import sys
sys.exit('bye bye')
SnekImportError("'sys' at line: 1, column:0")
Link time elapsed: 0.216 ms
import subprocess
SnekImportError("'subprocess' at line: 1, column:0")
Link time elapsed: 0.180 ms
[(1.0, 1.0), (False, "A"), 6].sort()
TypeError("'<' not supported between instances of 'int' and 'tuple'")
Link time elapsed: 0.683 ms
import math
math.prod([1, 0, 2, 3])
SnekImportError("'math' at line: 1, column:0")
Link time elapsed: 42.139 ms
import math
SnekImportError("'math' at line: 1, column:0")
Link time elapsed: 0.839 ms
class X:
    def __hash__(self):
        pair[:] = []
        return 13

pair = [X(), 123]
dict([pair])
FeatureNotAvailable('Sorry, ClassDef is not available in this evaluator at line: 1, column:0')
Link time elapsed: 0.949 ms
if a:= 3:
	print(a)
SyntaxError('invalid syntax', ('<unknown>', 1, 6, 'if a:= 3:\n'))
Link time elapsed: 0.151 ms
def simple():
    for number in (1,2):
        try:
            return number
        finally:
            continue

simple()
FeatureNotAvailable('Sorry, Continue is not available in this evaluator at line: 6, column:12')
Link time elapsed: 1.493 ms
def simple():
    for number in range(2):
        try:
            return number
        finally:
            continue

simple()
NameNotDefined("'range' is not defined at line: 2, column:18")
Link time elapsed: 0.876 ms
b = []
i = 2
while i > 0:
	b = [b, [b]]
	i = i - 1
b
[None, None, None, [[[], [[]]], [[[], [[]]]]]]
Link time elapsed: 1.278 ms
def greet(name):
    return f"Hello, {name}"

names = ["ed", "edd", "eddie"]
[greet(name) for name in names]
[None, None, ['Hello, ed', 'Hello, edd', 'Hello, eddie']]
Link time elapsed: 2.023 ms
x = 'foo' * 50000
str(x) * 50000
SnekArithmeticError('Sorry, I will not evalute something that long. at line: 1, column:4')
Link time elapsed: 0.311 ms
b = []
i = 20
while i > 0:
	b = [b, [b]]
	i = i - 1
b
ScopeTooLarge('Scope has used too much memory: 25100 > 20000.0 at line: 4, column:5')
Link time elapsed: 40.930 ms
a = [1,2,3,4,5,6,7,8,9,10]
[i*i for i in a]
[i**i for i in a ]
[1/i for i in a ]
[None,
 [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],
 [1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489, 10000000000],
 [1.0,
  0.5,
  0.3333333333333333,
  0.25,
  0.2,
  0.16666666666666666,
  0.14285714285714285,
  0.125,
  0.1111111111111111,
  0.1]]
Link time elapsed: 3.486 ms
b = []
i = 50
while i > 0:
	b = [b, [b]]
	i = i - 1
	
str(b)
ScopeTooLarge('Scope has used too much memory: 25100 > 20000.0 at line: 4, column:5')
Link time elapsed: 43.391 ms
a = [1,2,3,4,5]
[i*i for i in a]
[i**i for i in a ]
[1/i for i in a ]
[None,
 [1, 4, 9, 16, 25],
 [1, 4, 27, 256, 3125],
 [1.0, 0.5, 0.3333333333333333, 0.25, 0.2]]
Link time elapsed: 2.278 ms
a = [1,2,3,4,5]
[i*i for i in a]
[i**i for i in a ]
[None, [1, 4, 9, 16, 25], [1, 4, 27, 256, 3125]]
Link time elapsed: 1.679 ms
def crash():
    try:
        crash()
    except:
        crash()
1
crash()
2
CallTooDeep('Sorry, stack is to large. The MAX_CALL_DEPTH is 32.  at line: 5, column:8')
Link time elapsed: 7.658 ms
b = []
i = 50
while i > 0:
	b = [b, [b]]
	i = i - 1
b
ScopeTooLarge('Scope has used too much memory: 25100 > 20000.0 at line: 4, column:5')
Link time elapsed: 114.857 ms
def deep_but_shared(n):
	result = []
	while n > 0:
		result = [
			result, result, result, result, result, result, result, result,
			result, result, result, result, result, result, result, result,
			result, result, result, result, result, result, result, result,
			result, result, result, result, result, result, result, result,
			result, result, result, result, result, result, result, result,
			result, result, result, result, result, result, result, result,
		]
		n = n - 1
	return result

arr = deep_but_shared(20)
arr
ScopeTooLarge('Scope has used too much memory: 457016 > 20000.0 at line: 4, column:11')
Link time elapsed: 131.074 ms
", ".join(["hi", "world"])
['hi, world']
Link time elapsed: 0.452 ms
"".join(["hi", "world"])
['hiworld']
Link time elapsed: 0.391 ms