code
stringlengths
1
1.49M
vector
listlengths
0
7.38k
snippet
listlengths
0
7.38k
import goog.json strd = goog.json.serialize({ 'a': 45, 'b': [ 1, 2, 3, 4, { 'c': "stuff", 'd': "things", }], 'xyzzy': False, 'blorp': True }) print strd print goog.json.unsafeParse(strd) print goog.json.serialize(goog.json.unsafeParse(strd)) == strd
[ [ 1, 0, 0.0667, 0.0667, 0, 0.66, 0, 575, 0, 1, 0, 0, 575, 0, 0 ], [ 14, 0, 0.5, 0.6667, 0, 0.66, 0.25, 75, 3, 1, 0, 0, 50, 10, 1 ], [ 8, 0, 0.8667, 0.0667, 0, 0.66,...
[ "import goog.json", "strd = goog.json.serialize({\n 'a': 45,\n 'b': [\n 1, 2, 3, 4, {\n 'c': \"stuff\",\n 'd': \"things\",\n }],\n 'xyzzy': False,", "print(strd)", "print(goog.json.unsafeParse(strd))", "print(goog.json.serialize(goog.json.unsafeParse(strd)) == st...
import goog.math as gm K = 10000 def main(): print gm.clamp(408, 10, 100) print gm.modulo(-10, 3) print gm.lerp(0, 14, 0.25) a = 14 b = 14.0001 print gm.nearlyEquals(a, b) print gm.nearlyEquals(a, b, 0.01) print gm.standardAngle(480) print gm.toRadians(170) print gm.toDegrees(2...
[ [ 1, 0, 0.02, 0.02, 0, 0.66, 0, 190, 0, 1, 0, 0, 190, 0, 0 ], [ 14, 0, 0.06, 0.02, 0, 0.66, 0.3333, 126, 1, 0, 0, 0, 0, 1, 0 ], [ 2, 0, 0.5, 0.82, 0, 0.66, 0.66...
[ "import goog.math as gm", "K = 10000", "def main():\n print(gm.clamp(408, 10, 100))\n print(gm.modulo(-10, 3))\n print(gm.lerp(0, 14, 0.25))\n a = 14\n b = 14.0001\n print(gm.nearlyEquals(a, b))\n print(gm.nearlyEquals(a, b, 0.01))", " print(gm.clamp(408, 10, 100))", " print(gm.mo...
x = 3.14e159
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 2, 0 ] ]
[ "x = 3.14e159" ]
x = -15921590215012591L
[]
[]
(-124561-1) & 0200000000
[]
[]
x = 314159.
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 2, 0 ] ]
[ "x = 314159." ]
x = "doesn't "shrink", does it"
[]
[]
0xdeadc0de & 012345
[]
[]
-1*1/1+1*1//1 - ---1**1
[ [ 8, 0, 1, 1, 0, 0.66, 0, 0, 4, 0, 0, 0, 0, 0, 0 ] ]
[ "-1*1/1+1*1//1 - ---1**1" ]
x = 3E123
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 2, 0 ] ]
[ "x = 3E123" ]
x = 3e14159
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 2, 0 ] ]
[ "x = 3e14159" ]
0xff <= 255
[ [ 8, 0, 1, 1, 0, 0.66, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ]
[ "0xff <= 255" ]
import sys, time x = sys.modules['time'].time()
[ [ 1, 0, 0.5, 0.5, 0, 0.66, 0, 509, 0, 2, 0, 0, 509, 0, 0 ], [ 14, 0, 1, 0.5, 0, 0.66, 1, 190, 3, 0, 0, 0, 654, 10, 1 ] ]
[ "import sys, time", "x = sys.modules['time'].time()" ]
x+y = 3e-1230
[]
[]
def d01v_(a=1, *k, **w): pass
[ [ 2, 0, 1, 1, 0, 0.66, 0, 498, 0, 3, 0, 0, 0, 0, 0 ] ]
[ "def d01v_(a=1, *k, **w): pass" ]
0b01 <= 255
[ [ 8, 0, 1, 1, 0, 0.66, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ]
[ "0b01 <= 255" ]
y = ur"abc" + Ur"ABC" + uR"ABC" + UR"ABC"
[]
[]
x = .314159
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 2, 0 ] ]
[ "x = .314159" ]
def k(x): x += 2 x += 5
[ [ 2, 0, 0.75, 1, 0, 0.66, 0, 954, 0, 1, 0, 0, 0, 0, 0 ] ]
[ "def k(x):\n x += 2" ]
@staticmethod def foo(x,y): pass
[ [ 2, 0, 1, 0.5, 0, 0.66, 0, 528, 0, 2, 0, 0, 0, 0, 0 ] ]
[ "def foo(x,y): pass" ]
if 1 < 1 > 1 == 1 >= 5 <= 0x15 <= 0x12 != 1 and 5 in 1 not in 1 is 1 or 5 is not 1: pass
[ [ 4, 0, 1, 1, 0, 0.66, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ]
[ "if 1 < 1 > 1 == 1 >= 5 <= 0x15 <= 0x12 != 1 and 5 in 1 not in 1 is 1 or 5 is not 1: pass" ]
x = 1//1*1/5*12%0x12
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 4, 0, 0, 0, 0, 0, 0 ] ]
[ "x = 1//1*1/5*12%0x12" ]
0xFF & 0x15 | 1234
[ [ 8, 0, 1, 1, 0, 0.66, 0, 0, 4, 0, 0, 0, 0, 0, 0 ] ]
[ "0xFF & 0x15 | 1234" ]
x = 1 << 1 >> 5
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 4, 0, 0, 0, 0, 0, 0 ] ]
[ "x = 1 << 1 >> 5" ]
a = r'''this is some more stuff
[]
[]
x = u'abc' + U'ABC'
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 4, 0, 0, 0, 0, 0, 0 ] ]
[ "x = u'abc' + U'ABC'" ]
x = 0xfffffffffff
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 1, 0 ] ]
[ "x = 0xfffffffffff" ]
0xdeadbeef != -1
[ [ 8, 0, 1, 1, 0, 0.66, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ]
[ "0xdeadbeef != -1" ]
2134568 != 01231515
[]
[]
wee = """this is some stuff and
[]
[]
def d22(a, b, c=2, d=2, *k): pass
[ [ 2, 0, 1, 1, 0, 0.66, 0, 755, 0, 5, 0, 0, 0, 0, 0 ] ]
[ "def d22(a, b, c=2, d=2, *k): pass" ]
~1 ^ 1 & 1 |1 ^ -1
[ [ 8, 0, 1, 1, 0, 0.66, 0, 0, 4, 0, 0, 0, 0, 0, 0 ] ]
[ "~1 ^ 1 & 1 |1 ^ -1" ]
0o123 <= 0123
[]
[]
x = ur'abc' + Ur'ABC' + uR'ABC' + UR'ABC'
[]
[]
x = '"'; y = "'"
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 3, 0 ], [ 14, 0, 1, 1, 0, 0.66, 1, 304, 1, 0, 0, 0, 0, 3, 0 ] ]
[ "x = '\"'; y = \"'\"", "x = '\"'; y = \"'\"" ]
1 + 1
[ [ 8, 0, 1, 1, 0, 0.66, 0, 0, 4, 0, 0, 0, 0, 0, 0 ] ]
[ "1 + 1" ]
x = 123141242151251616110l
[]
[]
x = ''; y = ""
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 3, 0 ], [ 14, 0, 1, 1, 0, 0.66, 1, 304, 1, 0, 0, 0, 0, 3, 0 ] ]
[ "x = ''; y = \"\"", "x = ''; y = \"\"" ]
x = 1 - y + 15 - 01 + 0x124 + z + a[5]
[]
[]
01234567 > ~0x15
[]
[]
x = 3.14159
[ [ 14, 0, 1, 1, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 2, 0 ] ]
[ "x = 3.14159" ]
def f(): if True: if False: x =3 y = 4 return return 19
[ [ 2, 0, 0.5714, 1, 0, 0.66, 0, 899, 0, 0, 1, 0, 0, 0, 0 ], [ 4, 1, 0.6429, 0.8571, 1, 0.47, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 4, 2, 0.5714, 0.4286, 2, 0.1, 0, ...
[ "def f():\n if True:\n if False:\n x =3\n y = 4\n return\n return 19", " if True:\n if False:\n x =3\n y = 4\n return\n return 19", " if False:\n x =3\n y = 4", " x =3", " ...
x = 0L
[]
[]
def make_tree(item, depth): if not depth: return item, None, None item2 = item + item depth -= 1 return item, make_tree(item2 - 1, depth), make_tree(item2, depth) def check_tree(node): item, left, right = node if not left: return item return item + check_tree(left) - check_tree(right) def ...
[ [ 2, 0, 0.0938, 0.1562, 0, 0.66, 0, 92, 0, 2, 1, 0, 0, 0, 2 ], [ 4, 1, 0.0625, 0.0312, 1, 0.07, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 13, 2, 0.0625, 0.0312, 2, 0.17, 0...
[ "def make_tree(item, depth):\n if not depth: return item, None, None\n item2 = item + item\n depth -= 1\n return item, make_tree(item2 - 1, depth), make_tree(item2, depth)", " if not depth: return item, None, None", " if not depth: return item, None, None", " item2 = item + item", " ...
import sys def main(): cout = sys.stdout.write size = 4000 xr_size = range(size) xr_iter = range(50) bit = 128 byte_acc = 0 cout("P4\n%d %d\n" % (size, size)) size = float(size) for y in xr_size: fy = 2j * y / size - 1j for x in xr_size: z = 0j ...
[ [ 1, 0, 0.0256, 0.0256, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.5128, 0.8974, 0, 0.66, 0.5, 624, 0, 0, 0, 0, 0, 0, 9 ], [ 14, 1, 0.1026, 0.0256, 1, 0.6,...
[ "import sys", "def main():\n cout = sys.stdout.write\n size = 4000\n xr_size = range(size)\n xr_iter = range(50)\n bit = 128\n byte_acc = 0", " cout = sys.stdout.write", " size = 4000", " xr_size = range(size)", " xr_iter = range(50)", " bit = 128", " byte_acc = 0",...
def do(fmt, val): print fmt % val do("%d", 42) do("%x", 42) do("%o", 42) do("%d", 42L) do("%x", 42L) do("%o", 42L) do("%d", 4200000000000L) do("%x", 4200000000000L) do("%o", 4200000000000L) do("%d", 0x4200000000000L) do("%x", 0x4200000000000L) do("%o", 0x4200000000000L) do("%d", 0o4200000000000L) do("%x", 0o4200000...
[ [ 2, 0, 0.75, 1, 0, 0.66, 0, 245, 0, 2, 0, 0, 0, 0, 1 ], [ 8, 1, 1, 0.5, 1, 0.39, 0, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "def do(fmt, val):\n print(fmt % val)", " print(fmt % val)" ]
x = [0, 1, 2] print x x.insert(2, x.pop(0)) print x
[ [ 14, 0, 0.2, 0.2, 0, 0.66, 0, 190, 0, 0, 0, 0, 0, 5, 0 ], [ 8, 0, 0.4, 0.2, 0, 0.66, 0.3333, 535, 3, 1, 0, 0, 0, 0, 1 ], [ 8, 0, 0.6, 0.2, 0, 0.66, 0.6667, ...
[ "x = [0, 1, 2]", "print(x)", "x.insert(2, x.pop(0))", "print(x)" ]
x = ('OK',) print(x[0])
[ [ 14, 0, 0.5, 0.5, 0, 0.66, 0, 190, 0, 0, 0, 0, 0, 8, 0 ], [ 8, 0, 1, 0.5, 0, 0.66, 1, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "x = ('OK',)", "print(x[0])" ]
import pkga.pkgb.modc as c_me print c_me.stuff print c_me.things
[ [ 1, 0, 0.25, 0.25, 0, 0.66, 0, 812, 0, 1, 0, 0, 812, 0, 0 ], [ 8, 0, 0.75, 0.25, 0, 0.66, 0.5, 535, 3, 1, 0, 0, 0, 0, 1 ], [ 8, 0, 1, 0.25, 0, 0.66, 1, 535...
[ "import pkga.pkgb.modc as c_me", "print(c_me.stuff)", "print(c_me.things)" ]
x=4 x|=1 print x
[ [ 14, 0, 0.3333, 0.3333, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 1, 0 ], [ 8, 0, 1, 0.3333, 0, 0.66, 2, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "x=4", "print(x)" ]
# Test the comparison of sets l = [1,2,3,4,1,1] print l s = set(l) print s # Test the comparison of sets print '# self' print '# forwards' print s.isdisjoint(s) print s > s print s.issuperset(s) print s >= s print s == s print s != s print s.issubset(s) print s <= s print s < s print '# backwards' print s.isdisjoint(...
[ [ 14, 0, 0.069, 0.0345, 0, 0.66, 0, 810, 0, 0, 0, 0, 0, 5, 0 ], [ 8, 0, 0.1034, 0.0345, 0, 0.66, 0.0417, 535, 3, 1, 0, 0, 0, 0, 1 ], [ 14, 0, 0.1379, 0.0345, 0, 0.6...
[ "l = [1,2,3,4,1,1]", "print(l)", "s = set(l)", "print(s)", "print('# self')", "print('# forwards')", "print(s.isdisjoint(s))", "print(s > s)", "print(s.issuperset(s))", "print(s >= s)", "print(s == s)", "print(s != s)", "print(s.issubset(s))", "print(s <= s)", "print(s < s)", "print('#...
print("O"+"K")
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "print(\"O\"+\"K\")" ]
if None is None: print "OK"
[ [ 4, 0, 0.75, 1, 0, 0.66, 0, 0, 0, 0, 0, 0, 0, 0, 1 ], [ 8, 1, 1, 0.5, 1, 0.75, 0, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "if None is None:\n print(\"OK\")", " print(\"OK\")" ]
def f(): y = 0 while y == 0: y += 1 yield y for i in f(): print i
[ [ 2, 0, 0.375, 0.625, 0, 0.66, 0, 899, 0, 0, 0, 0, 0, 0, 0 ], [ 14, 1, 0.25, 0.125, 1, 0.67, 0, 304, 1, 0, 0, 0, 0, 1, 0 ], [ 5, 1, 0.5, 0.375, 1, 0.67, 1, ...
[ "def f():\n y = 0\n while y == 0:\n y += 1\n yield y", " y = 0", " while y == 0:\n y += 1\n yield y", " yield y", "for i in f():\n print(i)", " print(i)" ]
print False or False
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "print(False or False)" ]
class C: def __init__(self, data): self.data = data def pr(self): print self.data C("OK").pr()
[ [ 3, 0, 0.5, 0.8333, 0, 0.66, 0, 619, 0, 2, 0, 0, 0, 0, 1 ], [ 2, 1, 0.4167, 0.3333, 1, 0.5, 0, 555, 0, 2, 0, 0, 0, 0, 0 ], [ 14, 2, 0.5, 0.1667, 2, 0.02, 0, ...
[ "class C:\n def __init__(self, data):\n self.data = data\n def pr(self):\n print(self.data)", " def __init__(self, data):\n self.data = data", " self.data = data", " def pr(self):\n print(self.data)", " print(self.data)", "C(\"OK\").pr()" ]
if not "?" in "xyz": print "OK"
[]
[]
a = b,c = 1,2 print a[0] print a[1] print b print c
[ [ 14, 0, 0.2, 0.2, 0, 0.66, 0, 475, 0, 0, 0, 0, 0, 8, 0 ], [ 8, 0, 0.4, 0.2, 0, 0.66, 0.25, 535, 3, 1, 0, 0, 0, 0, 1 ], [ 8, 0, 0.6, 0.2, 0, 0.66, 0.5, 535,...
[ "a = b,c = 1,2", "print(a[0])", "print(a[1])", "print(b)", "print(c)" ]
x = 'OK',1 print x[0]
[ [ 14, 0, 0.5, 0.5, 0, 0.66, 0, 190, 0, 0, 0, 0, 0, 8, 0 ], [ 8, 0, 1, 0.5, 0, 0.66, 1, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "x = 'OK',1", "print(x[0])" ]
if 0 == 1: print "X" else: print "OK"
[ [ 4, 0, 0.625, 1, 0, 0.66, 0, 0, 0, 0, 0, 0, 0, 0, 2 ], [ 8, 1, 0.5, 0.25, 1, 0.76, 0, 535, 3, 1, 0, 0, 0, 0, 1 ], [ 8, 1, 1, 0.25, 1, 0.76, 1, 535, 3, ...
[ "if 0 == 1:\n print(\"X\")\nelse:\n print(\"OK\")", " print(\"X\")", " print(\"OK\")" ]
class O(object): pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(D,E): pass class A(B,C): pass print A.__bases__ print A.__mro__
[ [ 3, 0, 0.1, 0.1, 0, 0.66, 0, 720, 0, 0, 0, 0, 186, 0, 0 ], [ 3, 0, 0.2, 0.1, 0, 0.66, 0.125, 498, 0, 0, 0, 0, 720, 0, 0 ], [ 3, 0, 0.3, 0.1, 0, 0.66, 0.25, ...
[ "class O(object): pass", "class F(O): pass", "class E(O): pass", "class D(O): pass", "class C(D,F): pass", "class B(D,E): pass", "class A(B,C): pass", "print(A.__bases__)", "print(A.__mro__)" ]
print 3*7
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "print(3*7)" ]
print long print long(3.0) print long(3) print type(long(3.0)) print type(long(3))
[ [ 8, 0, 0.2, 0.2, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 1 ], [ 8, 0, 0.4, 0.2, 0, 0.66, 0.25, 535, 3, 1, 0, 0, 0, 0, 2 ], [ 8, 0, 0.6, 0.2, 0, 0.66, 0.5, 535, ...
[ "print(long)", "print(long(3.0))", "print(long(3))", "print(type(long(3.0)))", "print(type(long(3)))" ]
print [1,2,3].index(3)
[ [ 8, 0, 1, 1, 0, 0.66, 0, 780, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "print [1,2,3].index(3)" ]
print slice(1)
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 2 ] ]
[ "print(slice(1))" ]
def wee(waa, woo=True, wii=False): print waa, woo, wii wee("OK")
[ [ 2, 0, 0.5, 0.6667, 0, 0.66, 0, 48, 0, 3, 0, 0, 0, 0, 1 ], [ 8, 1, 0.6667, 0.3333, 1, 0.24, 0, 535, 3, 3, 0, 0, 0, 0, 1 ], [ 8, 0, 1, 0.3333, 0, 0.66, 1, 4...
[ "def wee(waa, woo=True, wii=False):\n print(waa, woo, wii)", " print(waa, woo, wii)", "wee(\"OK\")" ]
def test(x,y): return x+y r = test(3,5) print r
[ [ 2, 0, 0.375, 0.5, 0, 0.66, 0, 224, 0, 2, 1, 0, 0, 0, 0 ], [ 13, 1, 0.5, 0.25, 1, 0.89, 0, 0, 4, 0, 0, 0, 0, 0, 0 ], [ 14, 0, 0.75, 0.25, 0, 0.66, 0.5, 436...
[ "def test(x,y):\n return x+y", " return x+y", "r = test(3,5)", "print(r)" ]
class X: x = 4 x = X() stuff = x.x print stuff things = X.x print things
[ [ 3, 0, 0.1875, 0.25, 0, 0.66, 0, 783, 0, 0, 0, 0, 0, 0, 0 ], [ 14, 1, 0.25, 0.125, 1, 0.02, 0, 190, 1, 0, 0, 0, 0, 1, 0 ], [ 14, 0, 0.5, 0.125, 0, 0.66, 0.2, ...
[ "class X:\n x = 4", " x = 4", "x = X()", "stuff = x.x", "print(stuff)", "things = X.x", "print(things)" ]
# Tests the list functions. l = [1,1,2,3,5,8,13,21] print l print l.count(1) print l.reverse() print l print l.count(1) print l.count(0) print l.count(3) print l.index(5) print l.remove(5) print l.remove(1) print l.count(1) print l
[ [ 14, 0, 0.1429, 0.0714, 0, 0.66, 0, 810, 0, 0, 0, 0, 0, 5, 0 ], [ 8, 0, 0.2143, 0.0714, 0, 0.66, 0.0833, 535, 3, 1, 0, 0, 0, 0, 1 ], [ 8, 0, 0.2857, 0.0714, 0, 0.6...
[ "l = [1,1,2,3,5,8,13,21]", "print(l)", "print(l.count(1))", "print(l.reverse())", "print(l)", "print(l.count(1))", "print(l.count(0))", "print(l.count(3))", "print(l.index(5))", "print(l.remove(5))", "print(l.remove(1))", "print(l.count(1))", "print(l)" ]
def a(): x = "OK" print x del x print "after" a()
[ [ 2, 0, 0.5, 0.8333, 0, 0.66, 0, 475, 0, 0, 0, 0, 0, 0, 2 ], [ 14, 1, 0.3333, 0.1667, 1, 0.38, 0, 190, 1, 0, 0, 0, 0, 3, 0 ], [ 8, 1, 0.5, 0.1667, 1, 0.38, 0.5,...
[ "def a():\n x = \"OK\"\n print(x)\n del x\n print(\"after\")", " x = \"OK\"", " print(x)", " print(\"after\")", "a()" ]
class X: pass print repr(X()) print str(X())
[ [ 3, 0, 0.3333, 0.3333, 0, 0.66, 0, 783, 0, 0, 0, 0, 0, 0, 0 ], [ 8, 0, 0.6667, 0.3333, 0, 0.66, 0.5, 535, 3, 1, 0, 0, 0, 0, 3 ], [ 8, 0, 1, 0.3333, 0, 0.66, 1,...
[ "class X: pass", "print(repr(X()))", "print(str(X()))" ]
print [x*y for x in range(10) if x % 2 == 0 for y in range(10)]
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 3 ] ]
[ "print([x*y for x in range(10) if x % 2 == 0 for y in range(10)])" ]
a = range(17) del a[::-3] print a a = range(16) del a[::-3] print a a = range(17) del a[::-2] print a a = range(16) del a[::-2] print a
[ [ 14, 0, 0.0833, 0.0833, 0, 0.66, 0, 475, 3, 1, 0, 0, 816, 10, 1 ], [ 8, 0, 0.25, 0.0833, 0, 0.66, 0.2857, 535, 3, 1, 0, 0, 0, 0, 1 ], [ 14, 0, 0.3333, 0.0833, 0, 0...
[ "a = range(17)", "print(a)", "a = range(16)", "print(a)", "a = range(17)", "print(a)", "a = range(16)", "print(a)" ]
print 0xff
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "print(0xff)" ]
def yrange(n): for i in range(n): yield i print list(yrange(5))
[ [ 2, 0, 0.5, 0.75, 0, 0.66, 0, 187, 0, 1, 0, 0, 0, 0, 1 ], [ 6, 1, 0.625, 0.5, 1, 0.58, 0, 826, 3, 0, 0, 0, 0, 0, 1 ], [ 8, 2, 0.75, 0.25, 2, 0.03, 0, 0, ...
[ "def yrange(n):\n for i in range(n):\n yield i", " for i in range(n):\n yield i", " yield i", "print(list(yrange(5)))" ]
# to avoid constant-izing in python compiler def doadd(a,b): return a+b def dosub(a,b): return a-b print doadd(123, 12345678987654321) print doadd(-123, 12345678987654321) print doadd(-123, -12345678987654321) print doadd(123, -12345678987654321) print dosub(123, 12345678987654321) print dosub(12345678987654321...
[ [ 2, 0, 0.1923, 0.1538, 0, 0.66, 0, 313, 0, 2, 1, 0, 0, 0, 0 ], [ 13, 1, 0.2308, 0.0769, 1, 0.71, 0, 0, 4, 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0.3462, 0.1538, 0, 0.66, ...
[ "def doadd(a,b):\n return a+b", " return a+b", "def dosub(a,b):\n return a-b", " return a-b", "print(doadd(123, 12345678987654321))", "print(doadd(-123, 12345678987654321))", "print(doadd(-123, -12345678987654321))", "print(doadd(123, -12345678987654321))", "print(dosub(123, 123456789876...
# multiple instances of generator at the same time def genmaker(a, b): z = a*b def gen(y): for i in range(4): yield i,a,b,y,z return gen(a*a*b*b) g1 = genmaker(3, 4) g2 = genmaker(4, 5) print g1.next() print g2.next() print g1.next() print g2.next() print g1.next() print g2.next() pr...
[ [ 2, 0, 0.3095, 0.2857, 0, 0.66, 0, 808, 0, 2, 1, 0, 0, 0, 2 ], [ 14, 1, 0.2381, 0.0476, 1, 0.29, 0, 859, 4, 0, 0, 0, 0, 0, 0 ], [ 2, 1, 0.3333, 0.1429, 1, 0.29, ...
[ "def genmaker(a, b):\n z = a*b\n def gen(y):\n for i in range(4):\n yield i,a,b,y,z\n return gen(a*a*b*b)", " z = a*b", " def gen(y):\n for i in range(4):\n yield i,a,b,y,z", " for i in range(4):\n yield i,a,b,y,z", " yield i,a,...
print ord(chr(128))
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 3 ] ]
[ "print(ord(chr(128)))" ]
print str(range(-4,-8))[:5] print len(range(-4,-8))
[ [ 8, 0, 0.5, 0.5, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 3 ], [ 8, 0, 1, 0.5, 0, 0.66, 1, 535, 3, 1, 0, 0, 0, 0, 3 ] ]
[ "print(str(range(-4,-8))[:5])", "print(len(range(-4,-8)))" ]
class O(object): pass class A(O): pass class B(O): pass class C(O): pass class D(O): pass class E(O): pass class K1(A,B,C): pass class K2(D,B,E): pass class K3(D,A): pass class Z(K1,K2,K3): pass print K1.__mro__ print K2.__mro__ print K3.__mro__ print Z.__mro__
[ [ 3, 0, 0.0714, 0.0714, 0, 0.66, 0, 720, 0, 0, 0, 0, 186, 0, 0 ], [ 3, 0, 0.1429, 0.0714, 0, 0.66, 0.0769, 429, 0, 0, 0, 0, 720, 0, 0 ], [ 3, 0, 0.2143, 0.0714, 0, ...
[ "class O(object): pass", "class A(O): pass", "class B(O): pass", "class C(O): pass", "class D(O): pass", "class E(O): pass", "class K1(A,B,C): pass", "class K2(D,B,E): pass", "class K3(D,A): pass", "class Z(K1,K2,K3): pass", "print(K1.__mro__)", "print(K2.__mro__)", "print(K3.__mro__)", "p...
x = 1 n = 0 while x < 10: x = x + 1 if n == 2: continue n = n + 1 print n
[ [ 14, 0, 0.125, 0.125, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 1, 0 ], [ 14, 0, 0.25, 0.125, 0, 0.66, 0.3333, 773, 1, 0, 0, 0, 0, 1, 0 ], [ 5, 0, 0.625, 0.625, 0, 0.66, ...
[ "x = 1", "n = 0", "while x < 10:\n x = x + 1\n if n == 2:\n continue\n n = n + 1", " x = x + 1", " if n == 2:\n continue", " n = n + 1", "print(n)" ]
xyzy = [100,101,102,103,104,105,106,107] del xyzy print xyzy
[ [ 14, 0, 0.3333, 0.3333, 0, 0.66, 0, 100, 0, 0, 0, 0, 0, 5, 0 ], [ 8, 0, 1, 0.3333, 0, 0.66, 2, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "xyzy = [100,101,102,103,104,105,106,107]", "print(xyzy)" ]
class O(object): pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(E,D): pass class A(B,C): pass print A.__mro__
[ [ 3, 0, 0.125, 0.125, 0, 0.66, 0, 720, 0, 0, 0, 0, 186, 0, 0 ], [ 3, 0, 0.25, 0.125, 0, 0.66, 0.1429, 498, 0, 0, 0, 0, 720, 0, 0 ], [ 3, 0, 0.375, 0.125, 0, 0.66, ...
[ "class O(object): pass", "class F(O): pass", "class E(O): pass", "class D(O): pass", "class C(D,F): pass", "class B(E,D): pass", "class A(B,C): pass", "print(A.__mro__)" ]
print () == (1,) print () == () print (1,) == (1,) print (1,2) == (3,4) print (1,2) == (1,2) print (1,2) == (1,) print (1,2) == (1,2,3) print (1,2,3) == (1,2) print (1,2,3) == (1,2,3) print print () != (1,) print () != () print (1,) != (1,) print (1,2) != (3,4) print (1,2) != (1,2) print (1,2) != (1,) print (1,2) != (1...
[ [ 8, 0, 0.0169, 0.0169, 0, 0.66, 0, 0, 0, 0, 0, 0, 0, 0, 1 ], [ 8, 0, 0.0339, 0.0169, 0, 0.66, 0.0172, 0, 0, 0, 0, 0, 0, 0, 1 ], [ 8, 0, 0.0508, 0.0169, 0, 0.66, ...
[ "print () == (1,)", "print () == ()", "print (1,) == (1,)", "print (1,2) == (3,4)", "print (1,2) == (1,2)", "print (1,2) == (1,)", "print (1,2) == (1,2,3)", "print (1,2,3) == (1,2)", "print (1,2,3) == (1,2,3)", "print", "print () != (1,)", "print () != ()", "print (1,) != (1,)", "print (1,...
print str(range(-8,-4))[:5] print len(range(-8,-4)) print range(-8,-4)[0] print range(-8,-4)[1] print range(-8,-4)[-1]
[ [ 8, 0, 0.2, 0.2, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 3 ], [ 8, 0, 0.4, 0.2, 0, 0.66, 0.25, 535, 3, 1, 0, 0, 0, 0, 3 ], [ 8, 0, 0.6, 0.2, 0, 0.66, 0.5, 535, ...
[ "print(str(range(-8,-4))[:5])", "print(len(range(-8,-4)))", "print(range(-8,-4)[0])", "print(range(-8,-4)[1])", "print(range(-8,-4)[-1])" ]
print "a\0b".replace("\0", "c")
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 2 ] ]
[ "print(\"a\\0b\".replace(\"\\0\", \"c\"))" ]
def func(): return "dog" def wee(): assert 1 != 2 assert "dog" == func() wee()
[ [ 2, 0, 0.2143, 0.2857, 0, 0.66, 0, 856, 0, 0, 1, 0, 0, 0, 0 ], [ 13, 1, 0.2857, 0.1429, 1, 0.83, 0, 0, 1, 0, 0, 0, 0, 3, 0 ], [ 2, 0, 0.5714, 0.4286, 0, 0.66, ...
[ "def func():\n return \"dog\"", " return \"dog\"", "def wee():\n assert 1 != 2\n assert \"dog\" == func()", "wee()" ]
def test(): def fnc(): print "OK" print fnc() test()
[ [ 2, 0, 0.5, 0.8, 0, 0.66, 0, 224, 0, 0, 0, 0, 0, 0, 3 ], [ 2, 1, 0.5, 0.4, 1, 0.3, 0, 499, 0, 0, 0, 0, 0, 0, 1 ], [ 8, 2, 0.6, 0.2, 2, 0.37, 0, 535, 3,...
[ "def test():\n def fnc():\n print(\"OK\")\n print(fnc())", " def fnc():\n print(\"OK\")", " print(\"OK\")", " print(fnc())", "test()" ]
# Test that re-setting the value in a dict doesn't mess with its length d = {'foo':2} print len(d), d d['foo'] = 13 print len(d), d
[ [ 14, 0, 0.4, 0.2, 0, 0.66, 0, 355, 0, 0, 0, 0, 0, 6, 0 ], [ 8, 0, 0.6, 0.2, 0, 0.66, 0.3333, 535, 3, 2, 0, 0, 0, 0, 2 ], [ 14, 0, 0.8, 0.2, 0, 0.66, 0.6667, ...
[ "d = {'foo':2}", "print(len(d), d)", "d['foo'] = 13", "print(len(d), d)" ]
print [x*y for x in range(1,10) for y in range(1,x) if y%2 == 0]
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 1, 0, 0, 0, 0, 3 ] ]
[ "print([x*y for x in range(1,10) for y in range(1,x) if y%2 == 0])" ]
x=4 x*=3 print x
[ [ 14, 0, 0.3333, 0.3333, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 1, 0 ], [ 8, 0, 1, 0.3333, 0, 0.66, 2, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "x=4", "print(x)" ]
class Stuff: def blah(self, x, y=False): print x,y s = Stuff() s.blah("x",y="OK")
[ [ 3, 0, 0.4, 0.6, 0, 0.66, 0, 710, 0, 1, 0, 0, 0, 0, 1 ], [ 2, 1, 0.5, 0.4, 1, 0.27, 0, 485, 0, 3, 0, 0, 0, 0, 1 ], [ 8, 2, 0.6, 0.2, 2, 0.09, 0, 535, 3...
[ "class Stuff:\n def blah(self, x, y=False):\n print(x,y)", " def blah(self, x, y=False):\n print(x,y)", " print(x,y)", "s = Stuff()", "s.blah(\"x\",y=\"OK\")" ]
print 3,4,5
[ [ 8, 0, 1, 1, 0, 0.66, 0, 535, 3, 3, 0, 0, 0, 0, 1 ] ]
[ "print(3,4,5)" ]
x = 'OK' print x[0]
[ [ 14, 0, 0.5, 0.5, 0, 0.66, 0, 190, 1, 0, 0, 0, 0, 3, 0 ], [ 8, 0, 1, 0.5, 0, 0.66, 1, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "x = 'OK'", "print(x[0])" ]
for i in (1 for x in range(3)): print i
[ [ 6, 0, 0.75, 1, 0, 0.66, 0, 826, 5, 0, 0, 0, 0, 0, 2 ], [ 8, 1, 1, 0.5, 1, 0.67, 0, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "for i in (1 for x in range(3)):\n print(i)", " print(i)" ]
# Test the behaviour of sets l = [1,2,3,4,1,1] print l s = set(l) # Test the addition and removal of items print len(s), s s.add(100) print len(s), s s.discard(2) print len(s), s
[ [ 14, 0, 0.1818, 0.0909, 0, 0.66, 0, 810, 0, 0, 0, 0, 0, 5, 0 ], [ 8, 0, 0.2727, 0.0909, 0, 0.66, 0.1429, 535, 3, 1, 0, 0, 0, 0, 1 ], [ 14, 0, 0.3636, 0.0909, 0, 0....
[ "l = [1,2,3,4,1,1]", "print(l)", "s = set(l)", "print(len(s), s)", "s.add(100)", "print(len(s), s)", "s.discard(2)", "print(len(s), s)" ]
class X: pass x = X() print getattr(x, 'wee', 14) print getattr(X, 'doggy', 'OK')
[ [ 3, 0, 0.25, 0.25, 0, 0.66, 0, 783, 0, 0, 0, 0, 0, 0, 0 ], [ 14, 0, 0.5, 0.25, 0, 0.66, 0.3333, 190, 3, 0, 0, 0, 783, 10, 1 ], [ 8, 0, 0.75, 0.25, 0, 0.66, 0.6...
[ "class X: pass", "x = X()", "print(getattr(x, 'wee', 14))", "print(getattr(X, 'doggy', 'OK'))" ]
x = ["hello"] y = list(x) x[0] = "hi" print y[0]
[ [ 14, 0, 0.25, 0.25, 0, 0.66, 0, 190, 0, 0, 0, 0, 0, 5, 0 ], [ 14, 0, 0.5, 0.25, 0, 0.66, 0.3333, 304, 3, 1, 0, 0, 430, 10, 1 ], [ 14, 0, 0.75, 0.25, 0, 0.66, 0...
[ "x = [\"hello\"]", "y = list(x)", "x[0] = \"hi\"", "print(y[0])" ]
class Stuff: def __init__(self): self.x = lambda: self.things() def things(self): print "OK" y = Stuff() y.x()
[ [ 3, 0, 0.4286, 0.7143, 0, 0.66, 0, 710, 0, 2, 0, 0, 0, 0, 2 ], [ 2, 1, 0.3571, 0.2857, 1, 0.76, 0, 555, 0, 1, 0, 0, 0, 0, 1 ], [ 14, 2, 0.4286, 0.1429, 2, 0.7, ...
[ "class Stuff:\n def __init__(self):\n self.x = lambda: self.things()\n def things(self):\n print(\"OK\")", " def __init__(self):\n self.x = lambda: self.things()", " self.x = lambda: self.things()", " def things(self):\n print(\"OK\")", " print(\"OK\")",...
x = [] x.append(x) print({x:'OK'}[x])
[ [ 14, 0, 0.3333, 0.3333, 0, 0.66, 0, 190, 0, 0, 0, 0, 0, 5, 0 ], [ 8, 0, 0.6667, 0.3333, 0, 0.66, 0.5, 243, 3, 1, 0, 0, 0, 0, 1 ], [ 8, 0, 1, 0.3333, 0, 0.66, 1...
[ "x = []", "x.append(x)", "print({x:'OK'}[x])" ]