code stringlengths 1 1.49M | vector listlengths 0 7.38k | snippet listlengths 0 7.38k |
|---|---|---|
def test(t):
t = "O"+t
print t
test("K")
| [
[
2,
0,
0.5,
0.75,
0,
0.66,
0,
224,
0,
1,
0,
0,
0,
0,
1
],
[
14,
1,
0.5,
0.25,
1,
0.99,
0,
15,
4,
0,
0,
0,
0,
0,
0
],
[
8,
1,
0.75,
0.25,
1,
0.99,
1,
535,
... | [
"def test(t):\n t = \"O\"+t\n print(t)",
" t = \"O\"+t",
" print(t)",
"test(\"K\")"
] |
print str.lower("Hello")
x = [4,5,0]
list.sort(x)
print x
| [
[
8,
0,
0.25,
0.25,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
2
],
[
14,
0,
0.5,
0.25,
0,
0.66,
0.3333,
190,
0,
0,
0,
0,
0,
5,
0
],
[
8,
0,
0.75,
0.25,
0,
0.66,
0.6667... | [
"print(str.lower(\"Hello\"))",
"x = [4,5,0]",
"list.sort(x)",
"print(x)"
] |
def test(a,b):
return a+b
print test(1,1)+test(1,1)
| [
[
2,
0,
0.5,
0.6667,
0,
0.66,
0,
224,
0,
2,
1,
0,
0,
0,
0
],
[
13,
1,
0.6667,
0.3333,
1,
0.27,
0,
0,
4,
0,
0,
0,
0,
0,
0
],
[
8,
0,
1,
0.3333,
0,
0.66,
1,
5... | [
"def test(a,b):\n return a+b",
" return a+b",
"print(test(1,1)+test(1,1))"
] |
def wee():
print "from wee"
def waa():
print "from waa"
def woo():
print "from woo"
def blorp():
print "from blorp"
| [
[
2,
0,
0.1875,
0.25,
0,
0.66,
0,
48,
0,
0,
0,
0,
0,
0,
1
],
[
8,
1,
0.25,
0.125,
1,
0.55,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
2,
0,
0.4375,
0.25,
0,
0.66,
0.3333,... | [
"def wee():\n print(\"from wee\")",
" print(\"from wee\")",
"def waa():\n print(\"from waa\")",
" print(\"from waa\")",
"def woo():\n print(\"from woo\")",
" print(\"from woo\")",
"def blorp():\n print(\"from blorp\")",
" print(\"from blorp\")"
] |
x = 1
while x < 3:
break
x = x + 1
print x
| [
[
14,
0,
0.2,
0.2,
0,
0.66,
0,
190,
1,
0,
0,
0,
0,
1,
0
],
[
5,
0,
0.6,
0.6,
0,
0.66,
0.5,
0,
0,
0,
0,
0,
0,
0,
0
],
[
14,
1,
0.8,
0.2,
1,
0.55,
0,
190,
... | [
"x = 1",
"while x < 3:\n break\n x = x + 1",
" x = x + 1",
"print(x)"
] |
print min(3,8,2,6)
| [
[
8,
0,
1,
1,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
2
]
] | [
"print(min(3,8,2,6))"
] |
a = (1,2,3)
b = ('a', 'b', 'c')
for x in a+b:
print x
print "a:",a
print "b:",b
| [
[
14,
0,
0.1667,
0.1667,
0,
0.66,
0,
475,
0,
0,
0,
0,
0,
8,
0
],
[
14,
0,
0.3333,
0.1667,
0,
0.66,
0.25,
756,
0,
0,
0,
0,
0,
8,
0
],
[
6,
0,
0.5833,
0.3333,
0,
0.66... | [
"a = (1,2,3)",
"b = ('a', 'b', 'c')",
"for x in a+b:\n print(x)",
" print(x)",
"print(\"a:\",a)",
"print(\"b:\",b)"
] |
x = 5
x &= 7
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 = 5",
"print(x)"
] |
print [] or 5
| [
[
8,
0,
1,
1,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"print([] or 5)"
] |
print object.__bases__
print object.__mro__
class X(object): pass
class Y(X): pass
print(X.__bases__)
print(X.__mro__)
print(Y.__bases__)
print(Y.__mro__)
| [
[
8,
0,
0.125,
0.125,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.25,
0.125,
0,
0.66,
0.1429,
535,
3,
1,
0,
0,
0,
0,
1
],
[
3,
0,
0.375,
0.125,
0,
0.66,
0... | [
"print(object.__bases__)",
"print(object.__mro__)",
"class X(object): pass",
"class Y(X): pass",
"print(X.__bases__)",
"print(X.__mro__)",
"print(Y.__bases__)",
"print(Y.__mro__)"
] |
print str(range(0,5,3))[:5]
print len(range(0,5,3))
print range(0,5,3)[0]
print range(0,5,3)[1]
print range(0,5,3)[-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(0,5,3))[:5])",
"print(len(range(0,5,3)))",
"print(range(0,5,3)[0])",
"print(range(0,5,3)[1])",
"print(range(0,5,3)[-1])"
] |
print "abc"[1.5]
| [
[
8,
0,
1,
1,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"print(\"abc\"[1.5])"
] |
print repr((1,2,3))
print repr([1,2,3])
print repr({1:'ok', 2:'stuff'})
print repr("weewaa")
| [
[
8,
0,
0.25,
0.25,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
2
],
[
8,
0,
0.5,
0.25,
0,
0.66,
0.3333,
535,
3,
1,
0,
0,
0,
0,
2
],
[
8,
0,
0.75,
0.25,
0,
0.66,
0.6667,... | [
"print(repr((1,2,3)))",
"print(repr([1,2,3]))",
"print(repr({1:'ok', 2:'stuff'}))",
"print(repr(\"weewaa\"))"
] |
print "xOK"[1:]
| [
[
8,
0,
1,
1,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"print(\"xOK\"[1:])"
] |
from t279_sub import wee, blorp
wee()
blorp()
from t279_sub import waa as woo
woo()
| [
[
1,
0,
0.1667,
0.1667,
0,
0.66,
0,
130,
0,
2,
0,
0,
130,
0,
0
],
[
8,
0,
0.3333,
0.1667,
0,
0.66,
0.25,
48,
3,
0,
0,
0,
0,
0,
1
],
[
8,
0,
0.5,
0.1667,
0,
0.66,
... | [
"from t279_sub import wee, blorp",
"wee()",
"blorp()",
"from t279_sub import waa as woo",
"woo()"
] |
x = [0]*10
for i in range(10):
x[i] += i
x[i] += i*2
print x
| [
[
14,
0,
0.1429,
0.1429,
0,
0.66,
0,
190,
4,
0,
0,
0,
0,
0,
0
],
[
6,
0,
0.5714,
0.4286,
0,
0.66,
0.5,
826,
3,
0,
0,
0,
0,
0,
1
],
[
8,
0,
1,
0.1429,
0,
0.66,
1... | [
"x = [0]*10",
"for i in range(10):\n x[i] += i\n x[i] += i*2",
"print(x)"
] |
big = 0x1234567890abcdef12345L # 21 hex digits
print "'%x'" % big
print "'%x'" % -big
print "'%5x'" % -big
print "'%22x'" % -big
print "'%23x'" % -big
print "'%-23x'" % -big
print "'%023x'" % -big
print "'%-023x'" % -big
print "'%025x'" % -big
print "'%025x'" % big
print "'%0+25x'" % big
print "'%+25x'" % big
print "'... | [
[
8,
0,
0.0286,
0.0286,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.0571,
0.0286,
0,
0.66,
0.0323,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.0857,
0.0286,
0,
0.66... | [
"print(\"'%x'\" % big)",
"print(\"'%x'\" % -big)",
"print(\"'%5x'\" % -big)",
"print(\"'%22x'\" % -big)",
"print(\"'%23x'\" % -big)",
"print(\"'%-23x'\" % -big)",
"print(\"'%023x'\" % -big)",
"print(\"'%-023x'\" % -big)",
"print(\"'%025x'\" % -big)",
"print(\"'%025x'\" % big)",
"print(\"'%0+25x'... |
def test():
global x
x = "OK"
test()
print x
| [
[
2,
0,
0.4,
0.6,
0,
0.66,
0,
224,
0,
0,
0,
0,
0,
0,
0
],
[
14,
1,
0.6,
0.2,
1,
0.66,
0,
190,
1,
0,
0,
0,
0,
3,
0
],
[
8,
0,
0.8,
0.2,
0,
0.66,
0.5,
224,
... | [
"def test():\n global x\n x = \"OK\"",
" x = \"OK\"",
"test()",
"print(x)"
] |
def f(a, b, **c):
sortc = [(x,y) for x,y in c.items()]
sortc.sort()
print a, b, sortc
f(1, 2, d=4, e=5)
f(1, b=4, e=5)
f(a=1, b=4, e=5, f=6, g=7)
| [
[
2,
0,
0.3125,
0.5,
0,
0.66,
0,
899,
0,
3,
0,
0,
0,
0,
3
],
[
14,
1,
0.25,
0.125,
1,
0.92,
0,
934,
5,
0,
0,
0,
0,
0,
1
],
[
8,
1,
0.375,
0.125,
1,
0.92,
0.5,
... | [
"def f(a, b, **c):\n sortc = [(x,y) for x,y in c.items()]\n sortc.sort()\n print(a, b, sortc)",
" sortc = [(x,y) for x,y in c.items()]",
" sortc.sort()",
" print(a, b, sortc)",
"f(1, 2, d=4, e=5)",
"f(1, b=4, e=5)",
"f(a=1, b=4, e=5, f=6, g=7)"
] |
big = 012345670123456701234567012345670L # 32 octal digits
print "'%o'" % big
print "'%o'" % -big
print "'%5o'" % -big
print "'%33o'" % -big
print "'%34o'" % -big
print "'%-34o'" % -big
print "'%034o'" % -big
print "'%-034o'" % -big
print "'%036o'" % -big
print "'%036o'" % big
print "'%0+36o'" % big
print "'%+36o'" % ... | [
[
8,
0,
0.0256,
0.0256,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.0513,
0.0256,
0,
0.66,
0.0312,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.0769,
0.0256,
0,
0.66... | [
"print(\"'%o'\" % big)",
"print(\"'%o'\" % -big)",
"print(\"'%5o'\" % -big)",
"print(\"'%33o'\" % -big)",
"print(\"'%34o'\" % -big)",
"print(\"'%-34o'\" % -big)",
"print(\"'%034o'\" % -big)",
"print(\"'%-034o'\" % -big)",
"print(\"'%036o'\" % -big)",
"print(\"'%036o'\" % big)",
"print(\"'%0+36o'... |
x=1
if x == 1:
print "yes"
| [
[
14,
0,
0.3333,
0.3333,
0,
0.66,
0,
190,
1,
0,
0,
0,
0,
1,
0
],
[
4,
0,
0.8333,
0.6667,
0,
0.66,
1,
0,
0,
0,
0,
0,
0,
0,
1
],
[
8,
1,
1,
0.3333,
1,
0.69,
0,
... | [
"x=1",
"if x == 1:\n print(\"yes\")",
" print(\"yes\")"
] |
print 123456
print 12345678987654321567
print repr(12345678987654321567)
| [
[
8,
0,
0.3333,
0.3333,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.6667,
0.3333,
0,
0.66,
0.5,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
1,
0.3333,
0,
0.66,
1,... | [
"print(123456)",
"print(12345678987654321567)",
"print(repr(12345678987654321567))"
] |
x = 2
x ^= 7
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 = 2",
"print(x)"
] |
def domul(a,b):
return a*b
print domul(10, 123456789876543)
print domul(876543234567, 123456789876543)
print domul(-876543234567, 123456789876543)
print domul(-876543234567, -123456789876543)
print domul(876543234567, -123456789876543)
print domul(876543234567, 10)
print domul(876543234567, -10)
| [
[
2,
0,
0.1667,
0.2222,
0,
0.66,
0,
945,
0,
2,
1,
0,
0,
0,
0
],
[
13,
1,
0.2222,
0.1111,
1,
0.44,
0,
0,
4,
0,
0,
0,
0,
0,
0
],
[
8,
0,
0.3333,
0.1111,
0,
0.66,
... | [
"def domul(a,b):\n return a*b",
" return a*b",
"print(domul(10, 123456789876543))",
"print(domul(876543234567, 123456789876543))",
"print(domul(-876543234567, 123456789876543))",
"print(domul(-876543234567, -123456789876543))",
"print(domul(876543234567, -123456789876543))",
"print(domul(8765432... |
class A:
def __init__(self):
print "at0"
self.a = 'O'
self.b = 'x'
def test(self):
print "KO"
class B(A):
def __init__(self):
print "at1"
A.__init__(self)
self.b = 'K'
def test(self):
print self.a + self.b
print "at2"
B().test()
print "at3"... | [
[
3,
0,
0.2353,
0.4118,
0,
0.66,
0,
429,
0,
2,
0,
0,
0,
0,
2
],
[
2,
1,
0.2059,
0.2353,
1,
0.6,
0,
555,
0,
1,
0,
0,
0,
0,
1
],
[
8,
2,
0.1765,
0.0588,
2,
0.14,
... | [
"class A:\n def __init__(self):\n print(\"at0\")\n self.a = 'O'\n self.b = 'x'\n def test(self):\n print(\"KO\")",
" def __init__(self):\n print(\"at0\")\n self.a = 'O'\n self.b = 'x'",
" print(\"at0\")",
" self.a = 'O'",
" self.... |
var1 = "foo"
if isinstance(var1, str):
print "var1 is a string"
| [
[
14,
0,
0.3333,
0.3333,
0,
0.66,
0,
897,
1,
0,
0,
0,
0,
3,
0
],
[
4,
0,
0.8333,
0.6667,
0,
0.66,
1,
0,
3,
0,
0,
0,
0,
0,
2
],
[
8,
1,
1,
0.3333,
1,
0.39,
0,
... | [
"var1 = \"foo\"",
"if isinstance(var1, str):\n print(\"var1 is a string\")",
" print(\"var1 is a string\")"
] |
# Test set unions
# sets are un-ordered, though python seems to sort them sometimes...
# hence the testing for equality to known sets rather than printing.
s = set([2,3,4])
t = set([4,5,6])
u = set([1,2,3,4,5])
print s
print t
print u
print '# pair unions'
a = s.union(t)
b = s.union(u)
c = t.union(s)
d = t.union(u)
e =... | [
[
14,
0,
0.1026,
0.0256,
0,
0.66,
0,
553,
3,
1,
0,
0,
21,
10,
1
],
[
14,
0,
0.1282,
0.0256,
0,
0.66,
0.0312,
15,
3,
1,
0,
0,
21,
10,
1
],
[
14,
0,
0.1538,
0.0256,
0,
... | [
"s = set([2,3,4])",
"t = set([4,5,6])",
"u = set([1,2,3,4,5])",
"print(s)",
"print(t)",
"print(u)",
"print('# pair unions')",
"a = s.union(t)",
"b = s.union(u)",
"c = t.union(s)",
"d = t.union(u)",
"e = u.union(s)",
"f = u.union(t)",
"print(a == c)",
"print(a == set([2,3,4,5,6]))",
"pr... |
if "x" is "x" or "y" is "y": print "OK"
| [] | [] |
class Stuff:
def __init__(self):
self.modes = {
'wee': self.things
}
self.modes['wee']()
def things(self):
print "OK"
Stuff()
| [
[
3,
0,
0.5,
0.8889,
0,
0.66,
0,
710,
0,
2,
0,
0,
0,
0,
2
],
[
2,
1,
0.4444,
0.5556,
1,
0.2,
0,
555,
0,
1,
0,
0,
0,
0,
1
],
[
14,
2,
0.4444,
0.3333,
2,
0.63,
0,... | [
"class Stuff:\n def __init__(self):\n self.modes = {\n 'wee': self.things\n }\n self.modes['wee']()\n def things(self):\n print(\"OK\")",
" def __init__(self):\n self.modes = {\n 'wee': self.things\n }\n self.m... |
for i in "skulpt": print i
| [] | [] |
print int
print float
print int(3.0)
print float(3)
| [
[
8,
0,
0.25,
0.25,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.5,
0.25,
0,
0.66,
0.3333,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.75,
0.25,
0,
0.66,
0.6667,... | [
"print(int)",
"print(float)",
"print(int(3.0))",
"print(float(3))"
] |
class X:
pass
x = X()
print x.__class__
print str(x.__class__)
print repr(x.__class__)
| [
[
3,
0,
0.2143,
0.2857,
0,
0.66,
0,
783,
0,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.5714,
0.1429,
0,
0.66,
0.25,
190,
3,
0,
0,
0,
783,
10,
1
],
[
8,
0,
0.7143,
0.1429,
0,
0.... | [
"class X:\n pass",
"x = X()",
"print(x.__class__)",
"print(str(x.__class__))",
"print(repr(x.__class__))"
] |
a = (1 for x in range(3))
print a
for i in a:
print i
| [
[
14,
0,
0.25,
0.25,
0,
0.66,
0,
475,
5,
0,
0,
0,
0,
0,
1
],
[
8,
0,
0.5,
0.25,
0,
0.66,
0.5,
535,
3,
1,
0,
0,
0,
0,
1
],
[
6,
0,
0.875,
0.5,
0,
0.66,
1,
82... | [
"a = (1 for x in range(3))",
"print(a)",
"for i in a:\n print(i)",
" print(i)"
] |
a = 1,
print a
| [
[
14,
0,
0.5,
0.5,
0,
0.66,
0,
475,
0,
0,
0,
0,
0,
8,
0
],
[
8,
0,
1,
0.5,
0,
0.66,
1,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"a = 1,",
"print(a)"
] |
x = {'a':'OK'}
print x['a']
| [
[
14,
0,
0.5,
0.5,
0,
0.66,
0,
190,
0,
0,
0,
0,
0,
6,
0
],
[
8,
0,
1,
0.5,
0,
0.66,
1,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"x = {'a':'OK'}",
"print(x['a'])"
] |
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])"
] |
print "%s:%r:%d:%x" % ("dog", "cat", 23456, 999999999999L)
| [] | [] |
def stuff(n):
print not n
for x in range(-5, 5):
stuff(x)
| [
[
2,
0,
0.3,
0.4,
0,
0.66,
0,
686,
0,
1,
0,
0,
0,
0,
1
],
[
8,
1,
0.4,
0.2,
1,
0.44,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
6,
0,
0.9,
0.4,
0,
0.66,
1,
190,
3... | [
"def stuff(n):\n print(not n)",
" print(not n)",
"for x in range(-5, 5):\n stuff(x)",
" stuff(x)"
] |
def f():
for i in 1,2,3,4,5:
if i == 3: break
yield i
print list(f())
| [
[
2,
0,
0.5,
0.8,
0,
0.66,
0,
899,
0,
0,
0,
0,
0,
0,
0
],
[
6,
1,
0.6,
0.6,
1,
0.51,
0,
826,
0,
0,
0,
0,
0,
0,
0
],
[
4,
2,
0.6,
0.2,
2,
0.6,
0,
0,
0,
... | [
"def f():\n for i in 1,2,3,4,5:\n if i == 3: break\n yield i",
" for i in 1,2,3,4,5:\n if i == 3: break\n yield i",
" if i == 3: break",
" yield i",
"print(list(f()))"
] |
print 2e9
print 2e10
print 1e9
print 1e10
print 1e8
print 1e7
| [
[
8,
0,
0.1667,
0.1667,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.3333,
0.1667,
0,
0.66,
0.2,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.5,
0.1667,
0,
0.66,
... | [
"print(2e9)",
"print(2e10)",
"print(1e9)",
"print(1e10)",
"print(1e8)",
"print(1e7)"
] |
big = 123456789012345678901234567890L
print "'%d'" % big
print "'%d'" % -big
print "'%5d'" % -big
print "'%31d'" % -big
print "'%32d'" % -big
print "'%-32d'" % -big
print "'%032d'" % -big
print "'%-032d'" % -big
print "'%034d'" % -big
print "'%034d'" % big
print "'%0+34d'" % big
print "'%+34d'" % big
print "'%34d'" % b... | [
[
8,
0,
0.0588,
0.0588,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.1176,
0.0588,
0,
0.66,
0.0625,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.1765,
0.0588,
0,
0.66... | [
"print(\"'%d'\" % big)",
"print(\"'%d'\" % -big)",
"print(\"'%5d'\" % -big)",
"print(\"'%31d'\" % -big)",
"print(\"'%32d'\" % -big)",
"print(\"'%-32d'\" % -big)",
"print(\"'%032d'\" % -big)",
"print(\"'%-032d'\" % -big)",
"print(\"'%034d'\" % -big)",
"print(\"'%034d'\" % big)",
"print(\"'%0+34d'... |
class Stuff:
def __init__(self):
self.a = 0
self.b = 'b'
self.c = [1,2,3]
self.d = 100000000000000
s = Stuff()
s.a += 10
s.b += 'dog'
s.c += [9,10]
s.d += 10000
print s.a
print s.b
print s.c
print s.d
| [
[
3,
0,
0.2059,
0.3529,
0,
0.66,
0,
710,
0,
1,
0,
0,
0,
0,
0
],
[
2,
1,
0.2353,
0.2941,
1,
0.62,
0,
555,
0,
1,
0,
0,
0,
0,
0
],
[
14,
2,
0.1765,
0.0588,
2,
0.02,
... | [
"class Stuff:\n def __init__(self):\n self.a = 0\n self.b = 'b'\n self.c = [1,2,3]\n self.d = 100000000000000",
" def __init__(self):\n self.a = 0\n self.b = 'b'\n self.c = [1,2,3]\n self.d = 100000000000000",
" self.a = 0",
" self.b ... |
s='abcd'
print s[::2]
| [
[
14,
0,
0.5,
0.5,
0,
0.66,
0,
553,
1,
0,
0,
0,
0,
3,
0
],
[
8,
0,
1,
0.5,
0,
0.66,
1,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"s='abcd'",
"print(s[::2])"
] |
print False and False or False
print False or False and False
| [
[
8,
0,
0.5,
0.5,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
1,
0.5,
0,
0.66,
1,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"print(False and False or False)",
"print(False or False and False)"
] |
print [x*x for x in range(20) if x > 10 if x % 2 == 0]
| [
[
8,
0,
1,
1,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
2
]
] | [
"print([x*x for x in range(20) if x > 10 if x % 2 == 0])"
] |
print "+%s+" % "hello"
print "+%d+" % 10
print "%c" % "a"
print '%c' % 34
print '%c' % 36
print '%d' % 10
print '%c' % 0x7f
| [
[
8,
0,
0.1429,
0.1429,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.2857,
0.1429,
0,
0.66,
0.1667,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.4286,
0.1429,
0,
0.66... | [
"print(\"+%s+\" % \"hello\")",
"print(\"+%d+\" % 10)",
"print(\"%c\" % \"a\")",
"print('%c' % 34)",
"print('%c' % 36)",
"print('%d' % 10)",
"print('%c' % 0x7f)"
] |
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 2+3
| [
[
8,
0,
1,
1,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"print(2+3)"
] |
print 7 in {1:2,'a':7}
| [
[
8,
0,
1,
1,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"print(7 in {1:2,'a':7})"
] |
def test(): return
x = 1
print test()
| [
[
2,
0,
0.3333,
0.3333,
0,
0.66,
0,
224,
0,
0,
0,
0,
0,
0,
0
],
[
13,
1,
0.3333,
0.3333,
1,
0.29,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.6667,
0.3333,
0,
0.66,
... | [
"def test(): return",
"def test(): return",
"x = 1",
"print(test())"
] |
if 0 == 1:
print "X"
elif 1 == 1:
print "OK"
else:
print "Y"
| [
[
4,
0,
0.5833,
1,
0,
0.66,
0,
0,
0,
0,
0,
0,
0,
0,
3
],
[
8,
1,
0.3333,
0.1667,
1,
0.63,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
4,
1,
0.75,
0.6667,
1,
0.63,
1,
0... | [
"if 0 == 1:\n print(\"X\")\nelif 1 == 1:\n print(\"OK\")\nelse:\n print(\"Y\")",
" print(\"X\")",
"elif 1 == 1:\n print(\"OK\")\nelse:\n print(\"Y\")",
" print(\"OK\")",
" print(\"Y\")"
] |
print type(1)
print type(2**10)
print type(2**1024)
print type("wee")
| [
[
8,
0,
0.25,
0.25,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
2
],
[
8,
0,
0.5,
0.25,
0,
0.66,
0.3333,
535,
3,
1,
0,
0,
0,
0,
2
],
[
8,
0,
0.75,
0.25,
0,
0.66,
0.6667,... | [
"print(type(1))",
"print(type(2**10))",
"print(type(2**1024))",
"print(type(\"wee\"))"
] |
print str(range(-4,-8,-1))[:5]
print len(range(-4,-8,-1))
print range(-4,-8,-1)[0]
print range(-4,-8,-1)[1]
print range(-4,-8,-1)[-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(-4,-8,-1))[:5])",
"print(len(range(-4,-8,-1)))",
"print(range(-4,-8,-1)[0])",
"print(range(-4,-8,-1)[1])",
"print(range(-4,-8,-1)[-1])"
] |
t = [[y*10+x for x in range(0,10)] for y in range(0,10)]
print t[2][3]
| [
[
14,
0,
0.5,
0.5,
0,
0.66,
0,
15,
5,
0,
0,
0,
0,
0,
2
],
[
8,
0,
1,
0.5,
0,
0.66,
1,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"t = [[y*10+x for x in range(0,10)] for y in range(0,10)]",
"print(t[2][3])"
] |
# using obj[token] in JS doesn't work as a generic string dict
# make sure to use *both* hasOwnProperty and then get it, otherwise object
# builtins will return existence.
def toString():
print "wee"
class stuff:
def toString(self):
return "waa"
def valueOf(self):
return "stuff"
toString()... | [
[
2,
0,
0.2812,
0.125,
0,
0.66,
0,
661,
0,
0,
0,
0,
0,
0,
1
],
[
8,
1,
0.3125,
0.0625,
1,
0.54,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
3,
0,
0.5625,
0.3125,
0,
0.66,
... | [
"def toString():\n print(\"wee\")",
" print(\"wee\")",
"class stuff:\n def toString(self):\n return \"waa\"\n def valueOf(self):\n return \"stuff\"",
" def toString(self):\n return \"waa\"",
" return \"waa\"",
" def valueOf(self):\n return \"stuff\"",
... |
print [5]*10
print [1,2,3]*4
print (5,)*10
print (1,2,3)*4
print 10*[5]
print 4*[1,2,3]
print 10*(5,)
print 4*(1,2,3)
| [
[
8,
0,
0.125,
0.125,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.25,
0.125,
0,
0.66,
0.1429,
535,
3,
1,
0,
0,
0,
0,
1
],
[
8,
0,
0.375,
0.125,
0,
0.66,
0... | [
"print([5]*10)",
"print([1,2,3]*4)",
"print (5,)*10",
"print (1,2,3)*4",
"print(10*[5])",
"print(4*[1,2,3])",
"print(10*(5,))",
"print(4*(1,2,3))"
] |
x="OK"
print x
| [
[
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)"
] |
print 2 in [1,2,3]
| [
[
8,
0,
1,
1,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"print(2 in [1,2,3])"
] |
import goog.graphics as gfx
import goog.dom as dom
def main():
g = gfx.createSimpleGraphics(600, 200)
print g
fill = gfx.SolidFill('yellow')
stroke = gfx.Stroke(2, 'green')
g.drawRect(30, 10, 100, 80, stroke, fill)
stroke = gfx.Stroke(4, 'green')
g.drawImage(30, 110, 276, 110, 'http://www... | [
[
1,
0,
0.0256,
0.0256,
0,
0.66,
0,
78,
0,
1,
0,
0,
78,
0,
0
],
[
1,
0,
0.0513,
0.0256,
0,
0.66,
0.3333,
107,
0,
1,
0,
0,
107,
0,
0
],
[
2,
0,
0.5256,
0.8718,
0,
0.... | [
"import goog.graphics as gfx",
"import goog.dom as dom",
"def main():\n g = gfx.createSimpleGraphics(600, 200)\n print(g)\n fill = gfx.SolidFill('yellow')\n stroke = gfx.Stroke(2, 'green')\n\n g.drawRect(30, 10, 100, 80, stroke, fill)\n stroke = gfx.Stroke(4, 'green')",
" g = gfx.createSi... |
y = 1
| [
[
14,
0,
1,
1,
0,
0.66,
0,
304,
1,
0,
0,
0,
0,
1,
0
]
] | [
"y = 1"
] |
print x+2*3
| [
[
8,
0,
1,
1,
0,
0.66,
0,
535,
3,
1,
0,
0,
0,
0,
1
]
] | [
"print(x+2*3)"
] |
def f():
n = "OK"
print n
f()
| [
[
2,
0,
0.4167,
0.6667,
0,
0.66,
0,
899,
0,
0,
0,
0,
0,
0,
1
],
[
14,
1,
0.3333,
0.1667,
1,
0.32,
0,
773,
1,
0,
0,
0,
0,
3,
0
],
[
8,
1,
0.6667,
0.1667,
1,
0.32,
... | [
"def f():\n n = \"OK\"\n\n print(n)",
" n = \"OK\"",
" print(n)",
"f()"
] |
print '0"1'
print '2\'3'
print "4'5"
print "6\"7"
print '''8'9"0'''
| [
[
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,
1
],
[
8,
0,
0.6,
0.2,
0,
0.66,
0.5,
535,
... | [
"print('0\"1')",
"print('2\\'3')",
"print(\"4'5\")",
"print(\"6\\\"7\")",
"print('''8'9\"0''')"
] |
import ast
import sys
def astppdump(node):
def _format(node, indent):
#print node, len(indent)
if isinstance(node, ast.AST):
namelen = " "*(len(node.__class__.__name__)) + " "
fields = []
for a,b in ast.iter_fields(node):
fieldlen = len(a)*" "
... | [
[
1,
0,
0.037,
0.037,
0,
0.66,
0,
809,
0,
1,
0,
0,
809,
0,
0
],
[
1,
0,
0.0741,
0.037,
0,
0.66,
0.3333,
509,
0,
1,
0,
0,
509,
0,
0
],
[
2,
0,
0.5,
0.7407,
0,
0.66,
... | [
"import ast",
"import sys",
"def astppdump(node):\n def _format(node, indent):\n #print node, len(indent)\n if isinstance(node, ast.AST):\n namelen = \" \"*(len(node.__class__.__name__)) + \" \"\n fields = []\n for a,b in ast.iter_fields(node):\n ... |
#! /usr/bin/env python
"""Token constants (from "token.h")."""
# Taken from Python (r53757) and modified to include some tokens
# originally monkeypatched in by pgen2.tokenize
#--start constants--
ENDMARKER = 0
NAME = 1
NUMBER = 2
STRING = 3
NEWLINE = 4
INDENT = 5
DEDENT = 6
LPAR = 7
RPAR = 8
LSQB = 9
RSQB = 10
C... | [
[
8,
0,
0.0366,
0.0122,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.1098,
0.0122,
0,
0.66,
0.0159,
977,
1,
0,
0,
0,
0,
1,
0
],
[
14,
0,
0.122,
0.0122,
0,
0.66,... | [
"\"\"\"Token constants (from \"token.h\").\"\"\"",
"ENDMARKER = 0",
"NAME = 1",
"NUMBER = 2",
"STRING = 3",
"NEWLINE = 4",
"INDENT = 5",
"DEDENT = 6",
"LPAR = 7",
"RPAR = 8",
"LSQB = 9",
"RSQB = 10",
"COLON = 11",
"COMMA = 12",
"SEMI = 13",
"PLUS = 14",
"MINUS = 15",
"STAR = 16",
... |
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation.
# All rights reserved.
"""Tokenization help for Python programs.
generate_tokens(readline) is a generator that breaks a stream of
text into Python tokens. It accepts a readline-like method which is called
repeatedly to get the next line o... | [
[
8,
0,
0.0314,
0.0482,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.0587,
0.0021,
0,
0.66,
0.0172,
777,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.0618,
0.0042,
0,
0.66... | [
"\"\"\"Tokenization help for Python programs.\n\ngenerate_tokens(readline) is a generator that breaks a stream of\ntext into Python tokens. It accepts a readline-like method which is called\nrepeatedly to get the next line of input (or \"\" for EOF). It generates\n5-tuples with these members:\n\n the token typ... |
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Pgen imports
import grammar, token, tokenize
class PgenGrammar(grammar.Grammar):
pass
class ParserGenerator(object):
def __init__(self, filename, stream=None):
close_stream = None
... | [
[
1,
0,
0.013,
0.0026,
0,
0.66,
0,
260,
0,
3,
0,
0,
260,
0,
0
],
[
3,
0,
0.0195,
0.0052,
0,
0.66,
0.2,
344,
0,
0,
0,
0,
407,
0,
0
],
[
3,
0,
0.4492,
0.849,
0,
0.66,... | [
"import grammar, token, tokenize",
"class PgenGrammar(grammar.Grammar):\n pass",
"class ParserGenerator(object):\n\n def __init__(self, filename, stream=None):\n close_stream = None\n if stream is None:\n stream = open(filename)\n close_stream = stream.close\n se... |
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""This module defines the data structures used to represent a grammar.
These are a bit arcane because they are derived from the data
structures used by Python's 'pgen' parser generator.
There's also ... | [
[
8,
0,
0.0421,
0.0495,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0792,
0.005,
0,
0.66,
0.1667,
848,
0,
1,
0,
0,
848,
0,
0
],
[
1,
0,
0.0941,
0.005,
0,
0.66,
... | [
"\"\"\"This module defines the data structures used to represent a grammar.\n\nThese are a bit arcane because they are derived from the data\nstructures used by Python's 'pgen' parser generator.\n\nThere's also a table here mapping operators to their names in the\ntoken module; the Python tokenize module reports al... |
#! /usr/bin/env python
"""Generate JS code from an ASDL description."""
# TO DO
# handle fields that have a type but no name
import os, sys
import asdl
TABSIZE = 4
MAX_COL = 80
def get_c_type(name):
"""Return a string for the C name of the type.
This function special cases the default types provided by as... | [
[
8,
0,
0.0051,
0.0026,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0179,
0.0026,
0,
0.66,
0.0455,
688,
0,
2,
0,
0,
688,
0,
0
],
[
1,
0,
0.023,
0.0026,
0,
0.66,... | [
"\"\"\"Generate JS code from an ASDL description.\"\"\"",
"import os, sys",
"import asdl",
"TABSIZE = 4",
"MAX_COL = 80",
"def get_c_type(name):\n \"\"\"Return a string for the C name of the type.\n\n This function special cases the default types provided by asdl:\n identifier, string, int, bool.... |
__author__ = 'bmiller'
def testEqual(actual, expected):
if type(expected) == type(1):
if actual == expected:
print('Pass')
return True
elif type(expected) == type(1.11):
if abs(actual-expected) < 0.00001:
print('Pass')
return True
else:
... | [
[
14,
0,
0.0476,
0.0476,
0,
0.66,
0,
777,
1,
0,
0,
0,
0,
3,
0
],
[
2,
0,
0.4762,
0.7143,
0,
0.66,
0.5,
214,
0,
2,
1,
0,
0,
0,
11
],
[
4,
1,
0.4524,
0.5714,
1,
0.71,... | [
"__author__ = 'bmiller'",
"def testEqual(actual, expected):\n if type(expected) == type(1):\n if actual == expected:\n print('Pass')\n return True\n elif type(expected) == type(1.11):\n if abs(actual-expected) < 0.00001:\n print('Pass')",
" if type(expecte... |
s = """Gur Mra bs Clguba, ol Gvz Crgref
Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Pbzcyrk vf orggre guna pbzcyvpngrq.
Syng vf orggre guna arfgrq.
Fcnefr vf orggre guna qrafr.
Ernqnovyvgl pbhagf.
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
Nygubhtu cenpg... | [
[
14,
0,
0.3929,
0.75,
0,
0.66,
0,
553,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.8214,
0.0357,
0,
0.66,
0.3333,
355,
0,
0,
0,
0,
0,
6,
0
],
[
6,
0,
0.8929,
0.1071,
0,
0.66... | [
"s = \"\"\"Gur Mra bs Clguba, ol Gvz Crgref\n\nOrnhgvshy vf orggre guna htyl.\nRkcyvpvg vf orggre guna vzcyvpvg.\nFvzcyr vf orggre guna pbzcyrk.\nPbzcyrk vf orggre guna pbzcyvpngrq.\nSyng vf orggre guna arfgrq.\nFcnefr vf orggre guna qrafr.",
"d = {}",
"for c in (65, 97):\n for i in range(26):\n d[chr... |
# JSLint doesn't allow/support disabling the requirement for braces around
# blocks, and that's one uglification I refuse to perform in the service of a
# lint.
#
# There are of course lots of other intelligent things JSLint has to say
# because it's just too easy in JS to do something that (e.g.) IE won't like.
# So, ... | [
[
1,
0,
0.1818,
0.013,
0,
0.66,
0,
394,
0,
2,
0,
0,
394,
0,
0
],
[
1,
0,
0.1948,
0.013,
0,
0.66,
0.2,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.2078,
0.013,
0,
0.66,
... | [
"from subprocess import Popen, PIPE",
"import sys",
"import re",
"def remapError(linestarts, line, col, err):\n if len(linestarts) == 0:\n # none supplied on command line\n return \"%s:%d:%d: %s\" % (sys.argv[1], line, col - 1, err)\n\n for i in range(len(linestarts)):\n if line > l... |
# San Angeles Observation
# Original C version Copyright 2004-2005 Jetro Lauha
# Web: http://iki.fi/jetro/
#
# BSD-license.
#
# Javascript version by Ken Waters
# Skulpt (Python) version by Scott Graham
import webgl
ShapeParams = [
# m a b n1 n2 n3 m a b n1 n2 n3 res1... | [
[
1,
0,
0.02,
0.002,
0,
0.66,
0,
201,
0,
1,
0,
0,
201,
0,
0
],
[
14,
0,
0.047,
0.048,
0,
0.66,
0.0294,
183,
0,
0,
0,
0,
0,
5,
0
],
[
3,
0,
0.081,
0.012,
0,
0.66,
... | [
"import webgl",
"ShapeParams = [\n # m a b n1 n2 n3 m a b n1 n2 n3 res1 res2 scale (org.res1,res2)\n [10, 1, 2, 90, 1, -45, 8, 1, 1, -1, 1, -0.4 , 20, 30, 2], # 40, 60\n [10, 1, 2, 90, 1, -45, 4, 1, 1, ... |
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import os
from django.utils import simplejson
from google.appengine.ext import db
class MainPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/html'
path = os.pat... | [
[
1,
0,
0.0164,
0.0164,
0,
0.66,
0,
167,
0,
1,
0,
0,
167,
0,
0
],
[
1,
0,
0.0328,
0.0164,
0,
0.66,
0.0833,
327,
0,
1,
0,
0,
327,
0,
0
],
[
1,
0,
0.0492,
0.0164,
0,
... | [
"from google.appengine.ext import webapp",
"from google.appengine.ext.webapp.util import run_wsgi_app",
"import os",
"from django.utils import simplejson",
"from google.appengine.ext import db",
"class MainPage(webapp.RequestHandler):\n def get(self):\n self.response.headers['Content-Type'] = 't... |
import sys
import webgl
import webgl.primitives
import webgl.models
import webgl.matrix4 as m4
def main():
print "Starting up..."
gl = webgl.Context("canvas")
sh = webgl.Shader(gl, VertexShader, FragmentShader)
sh.use()
m = webgl.models.Model(sh, webgl.primitives.createCube(1), [])
eyePos... | [
[
1,
0,
0.0118,
0.0118,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.0235,
0.0118,
0,
0.66,
0.125,
201,
0,
1,
0,
0,
201,
0,
0
],
[
1,
0,
0.0353,
0.0118,
0,
0... | [
"import sys",
"import webgl",
"import webgl.primitives",
"import webgl.models",
"import webgl.matrix4 as m4",
"def main():\n print(\"Starting up...\")\n gl = webgl.Context(\"canvas\")\n sh = webgl.Shader(gl, VertexShader, FragmentShader)\n sh.use()\n \n m = webgl.models.Model(sh, webgl.p... |
"""
quick hack script to convert from quake2 .bsp to simple format to draw. drops
most information. keeps only raw polys and lightmaps.
makes .blv and .llv file (big and little endian level)
file format is
'BLV1' or 'LLV1'
int texwidth
int texheight
int numtris
float startx, starty, s... | [
[
8,
0,
0.0724,
0.1402,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1495,
0.0047,
0,
0.66,
0.0909,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.1542,
0.0047,
0,
0.66... | [
"\"\"\"\n\nquick hack script to convert from quake2 .bsp to simple format to draw. drops\nmost information. keeps only raw polys and lightmaps.\n\nmakes .blv and .llv file (big and little endian level)\n\nfile format is",
"import os",
"import sys",
"import struct",
"def strunpack(stream, format):\n retur... |
#====================================================================
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you ... | [
[
1,
0,
0.3514,
0.0135,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.3649,
0.0135,
0,
0.66,
0.1111,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.3784,
0.0135,
0,
... | [
"import os",
"import re",
"import tempfile",
"import shutil",
"ignore_pattern = re.compile('^(.svn|target|bin|classes)')",
"java_pattern = re.compile('^.*\\.java')",
"annot_pattern = re.compile('import org\\.apache\\.http\\.annotation\\.')",
"def process_dir(dir):\n files = os.listdir(dir)\n for... |
import rope.base.oi.soi
from rope.base import pynames
from rope.base.pynames import *
class AssignedName(pynames.AssignedName):
def __init__(self, lineno=None, module=None, pyobject=None):
self.lineno = lineno
self.module = module
self.assignments = []
self.pyobject = _Inferred(se... | [
[
1,
0,
0.0182,
0.0182,
0,
0.66,
0,
666,
0,
1,
0,
0,
666,
0,
0
],
[
1,
0,
0.0364,
0.0182,
0,
0.66,
0.2,
632,
0,
1,
0,
0,
632,
0,
0
],
[
1,
0,
0.0545,
0.0182,
0,
0.6... | [
"import rope.base.oi.soi",
"from rope.base import pynames",
"from rope.base.pynames import *",
"class AssignedName(pynames.AssignedName):\n\n def __init__(self, lineno=None, module=None, pyobject=None):\n self.lineno = lineno\n self.module = module\n self.assignments = []\n self... |
from rope.base import exceptions, change, taskhandle
class History(object):
"""A class that holds project history"""
def __init__(self, project, maxundos=None):
self.project = project
self._undo_list = []
self._redo_list = []
self._maxundos = maxundos
self._load_histor... | [
[
1,
0,
0.0043,
0.0043,
0,
0.66,
0,
632,
0,
3,
0,
0,
632,
0,
0
],
[
3,
0,
0.4468,
0.8638,
0,
0.66,
0.5,
941,
0,
22,
0,
0,
186,
0,
72
],
[
8,
1,
0.0213,
0.0043,
1,
0... | [
"from rope.base import exceptions, change, taskhandle",
"class History(object):\n \"\"\"A class that holds project history\"\"\"\n\n def __init__(self, project, maxundos=None):\n self.project = project\n self._undo_list = []\n self._redo_list = []\n self._maxundos = maxundos",
... |
import bisect
import keyword
import rope.base.simplify
def get_name_at(resource, offset):
source_code = resource.read()
word_finder = Worder(source_code)
return word_finder.get_word_at(offset)
class Worder(object):
"""A class for finding boundaries of words and expressions
Note that in these m... | [
[
1,
0,
0.0019,
0.0019,
0,
0.66,
0,
325,
0,
1,
0,
0,
325,
0,
0
],
[
1,
0,
0.0038,
0.0019,
0,
0.66,
0.2,
454,
0,
1,
0,
0,
454,
0,
0
],
[
1,
0,
0.0076,
0.0019,
0,
0.6... | [
"import bisect",
"import keyword",
"import rope.base.simplify",
"def get_name_at(resource, offset):\n source_code = resource.read()\n word_finder = Worder(source_code)\n return word_finder.get_word_at(offset)",
" source_code = resource.read()",
" word_finder = Worder(source_code)",
" r... |
import bisect
import difflib
import sys
import warnings
import rope.base.oi.doa
import rope.base.oi.objectinfo
import rope.base.oi.soa
from rope.base import ast, exceptions, taskhandle, utils, stdmods
from rope.base.exceptions import ModuleNotFoundError
from rope.base.pyobjectsdef import PyModule, PyPackage, PyClass
i... | [
[
1,
0,
0.0024,
0.0024,
0,
0.66,
0,
325,
0,
1,
0,
0,
325,
0,
0
],
[
1,
0,
0.0049,
0.0024,
0,
0.66,
0.0588,
866,
0,
1,
0,
0,
866,
0,
0
],
[
1,
0,
0.0073,
0.0024,
0,
... | [
"import bisect",
"import difflib",
"import sys",
"import warnings",
"import rope.base.oi.doa",
"import rope.base.oi.objectinfo",
"import rope.base.oi.soa",
"from rope.base import ast, exceptions, taskhandle, utils, stdmods",
"from rope.base.exceptions import ModuleNotFoundError",
"from rope.base.p... |
import UserDict
class ObjectDB(object):
def __init__(self, db, validation):
self.db = db
self.validation = validation
self.observers = []
self.files = db.files
def validate_files(self):
for file in list(self.files):
if not self.validation.is_file_valid(fil... | [
[
1,
0,
0.0057,
0.0057,
0,
0.66,
0,
351,
0,
1,
0,
0,
351,
0,
0
],
[
3,
0,
0.2886,
0.5371,
0,
0.66,
0.1429,
130,
0,
16,
0,
0,
186,
0,
39
],
[
2,
1,
0.0457,
0.0286,
1,
... | [
"import UserDict",
"class ObjectDB(object):\n\n def __init__(self, db, validation):\n self.db = db\n self.validation = validation\n self.observers = []\n self.files = db.files",
" def __init__(self, db, validation):\n self.db = db\n self.validation = validation\n ... |
"""Provides classes for persisting `PyObject`\s"""
import os
import re
import rope.base.builtins
from rope.base import exceptions
class PyObjectToTextual(object):
"""For transforming `PyObject` to textual form
This can be used for storing `PyObjects` in files. Use
`TextualToPyObject` for converting bac... | [
[
8,
0,
0.0035,
0.0035,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.007,
0.0035,
0,
0.66,
0.1429,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0105,
0.0035,
0,
0.66,... | [
"\"\"\"Provides classes for persisting `PyObject`\\s\"\"\"",
"import os",
"import re",
"import rope.base.builtins",
"from rope.base import exceptions",
"class PyObjectToTextual(object):\n \"\"\"For transforming `PyObject` to textual form\n\n This can be used for storing `PyObjects` in files. Use\n ... |
"""A module for inferring objects
For more information see the documentation in `rope.base.oi`
package.
"""
import rope.base.builtins
import rope.base.pynames
import rope.base.pyobjects
from rope.base import evaluate, utils, arguments
_ignore_inferred = utils.ignore_exception(
rope.base.pyobjects.IsBeingInferre... | [
[
8,
0,
0.0188,
0.0323,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0376,
0.0054,
0,
0.66,
0.0556,
74,
0,
1,
0,
0,
74,
0,
0
],
[
1,
0,
0.043,
0.0054,
0,
0.66,
... | [
"\"\"\"A module for inferring objects\n\nFor more information see the documentation in `rope.base.oi`\npackage.\n\n\"\"\"",
"import rope.base.builtins",
"import rope.base.pynames",
"import rope.base.pyobjects",
"from rope.base import evaluate, utils, arguments",
"_ignore_inferred = utils.ignore_exception(... |
def __rope_start_everything():
import os
import sys
import socket
import cPickle as pickle
import marshal
import inspect
import types
import threading
class _MessageSender(object):
def send_data(self, data):
pass
class _SocketSender(_MessageSender):
... | [
[
2,
0,
0.4953,
0.9763,
0,
0.66,
0,
940,
0,
0,
1,
0,
0,
0,
84
],
[
1,
1,
0.0142,
0.0047,
1,
0.7,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
1,
0.019,
0.0047,
1,
0.7,
... | [
"def __rope_start_everything():\n import os\n import sys\n import socket\n import cPickle as pickle\n import marshal\n import inspect\n import types",
" import os",
" import sys",
" import socket",
" import cPickle as pickle",
" import marshal",
" import inspect",
... |
"""Rope object analysis and inference package
Rope makes some simplifying assumptions about a python program. It
assumes that a program only performs assignments and function calls.
Tracking assignments is simple and `PyName` objects handle that. The
main problem is function calls. Rope uses these two approaches fo... | [
[
8,
0,
0.5132,
1,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
]
] | [
"\"\"\"Rope object analysis and inference package\n\nRope makes some simplifying assumptions about a python program. It\nassumes that a program only performs assignments and function calls.\nTracking assignments is simple and `PyName` objects handle that. The\nmain problem is function calls. Rope uses these two ... |
from rope.base.oi import objectdb
class MemoryDB(objectdb.FileDict):
def __init__(self, project, persist=None):
self.project = project
self._persist = persist
self.files = self
self._load_files()
self.project.data_files.add_write_hook(self.write)
def _load_files(self)... | [
[
1,
0,
0.0094,
0.0094,
0,
0.66,
0,
897,
0,
1,
0,
0,
897,
0,
0
],
[
3,
0,
0.283,
0.5,
0,
0.66,
0.3333,
835,
0,
11,
0,
0,
28,
0,
8
],
[
2,
1,
0.0802,
0.0566,
1,
0.08... | [
"from rope.base.oi import objectdb",
"class MemoryDB(objectdb.FileDict):\n\n def __init__(self, project, persist=None):\n self.project = project\n self._persist = persist\n self.files = self\n self._load_files()\n self.project.data_files.add_write_hook(self.write)",
" de... |
import warnings
from rope.base import exceptions, resourceobserver
from rope.base.oi import objectdb, memorydb, transform
class ObjectInfoManager(object):
"""Stores object information
It uses an instance of `objectdb.ObjectDB` for storing
information.
"""
def __init__(self, project):
s... | [
[
1,
0,
0.0043,
0.0043,
0,
0.66,
0,
358,
0,
1,
0,
0,
358,
0,
0
],
[
1,
0,
0.0129,
0.0043,
0,
0.66,
0.2,
632,
0,
2,
0,
0,
632,
0,
0
],
[
1,
0,
0.0172,
0.0043,
0,
0.6... | [
"import warnings",
"from rope.base import exceptions, resourceobserver",
"from rope.base.oi import objectdb, memorydb, transform",
"class ObjectInfoManager(object):\n \"\"\"Stores object information\n\n It uses an instance of `objectdb.ObjectDB` for storing\n information.\n\n \"\"\"",
" \"\"\... |
import rope.base.ast
import rope.base.oi.soi
import rope.base.pynames
from rope.base import pyobjects, evaluate, astutils, arguments
def analyze_module(pycore, pymodule, should_analyze,
search_subscopes, followed_calls):
"""Analyze `pymodule` for static object inference
Analyzes scopes for... | [
[
1,
0,
0.0074,
0.0074,
0,
0.66,
0,
442,
0,
1,
0,
0,
442,
0,
0
],
[
1,
0,
0.0147,
0.0074,
0,
0.66,
0.1429,
666,
0,
1,
0,
0,
666,
0,
0
],
[
1,
0,
0.0221,
0.0074,
0,
... | [
"import rope.base.ast",
"import rope.base.oi.soi",
"import rope.base.pynames",
"from rope.base import pyobjects, evaluate, astutils, arguments",
"def analyze_module(pycore, pymodule, should_analyze,\n search_subscopes, followed_calls):\n \"\"\"Analyze `pymodule` for static object infere... |
# The default ``config.py``
def set_prefs(prefs):
"""This function is called before opening the project"""
# Specify which files and folders to ignore in the project.
# Changes to ignored resources are not added to the history and
# VCSs. Also they are not returned in `Project.get_files()`.
# No... | [
[
2,
0,
0.4941,
0.9059,
0,
0.66,
0,
770,
0,
1,
0,
0,
0,
0,
0
],
[
8,
1,
0.0588,
0.0118,
1,
0.9,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
1,
0.1941,
0.0235,
1,
0.9,
0.... | [
"def set_prefs(prefs):\n \"\"\"This function is called before opening the project\"\"\"\n\n # Specify which files and folders to ignore in the project.\n # Changes to ignored resources are not added to the history and\n # VCSs. Also they are not returned in `Project.get_files()`.\n # Note that ``?``... |
from rope.base import ast
def get_name_levels(node):
"""Return a list of ``(name, level)`` tuples for assigned names
The `level` is `None` for simple assignments and is a list of
numbers for tuple assignments for example in::
a, (b, c) = x
The levels for for `a` is ``[0]``, for `b` is ``[1, 0... | [
[
1,
0,
0.0164,
0.0164,
0,
0.66,
0,
632,
0,
1,
0,
0,
632,
0,
0
],
[
2,
0,
0.1803,
0.2459,
0,
0.66,
0.5,
528,
0,
1,
1,
0,
0,
0,
2
],
[
8,
1,
0.1639,
0.1803,
1,
0.61,... | [
"from rope.base import ast",
"def get_name_levels(node):\n \"\"\"Return a list of ``(name, level)`` tuples for assigned names\n\n The `level` is `None` for simple assignments and is a list of\n numbers for tuple assignments for example in::\n\n a, (b, c) = x",
" \"\"\"Return a list of ``(name, ... |
"""A module to ease code analysis
This module is here to help source code analysis.
"""
import re
from rope.base import codeanalyze, utils
@utils.cached(7)
def real_code(source):
"""Simplify `source` for analysis
It replaces:
* comments with spaces
* strs with a new str filled with spaces
* im... | [
[
8,
0,
0.0455,
0.0727,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0909,
0.0182,
0,
0.66,
0.1667,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.1273,
0.0182,
0,
0.66... | [
"\"\"\"A module to ease code analysis\n\nThis module is here to help source code analysis.\n\"\"\"",
"import re",
"from rope.base import codeanalyze, utils",
"def real_code(source):\n \"\"\"Simplify `source` for analysis\n\n It replaces:\n\n * comments with spaces\n * strs with a new str filled wi... |
"""Project file system commands.
This modules implements file system operations used by rope. Different
version control systems can be supported by implementing the interface
provided by `FileSystemCommands` class. See `SubversionCommands` and
`MercurialCommands` for example.
"""
import os
import shutil
import subp... | [
[
8,
0,
0.0169,
0.03,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0337,
0.0037,
0,
0.66,
0.0625,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0375,
0.0037,
0,
0.66,
... | [
"\"\"\"Project file system commands.\n\nThis modules implements file system operations used by rope. Different\nversion control systems can be supported by implementing the interface\nprovided by `FileSystemCommands` class. See `SubversionCommands` and\n`MercurialCommands` for example.\n\n\"\"\"",
"import os",
... |
from rope.base.fscommands import _decode_data
from rope.base import ast, exceptions, utils
class PyObject(object):
def __init__(self, type_):
if type_ is None:
type_ = self
self.type = type_
def get_attributes(self):
if self.type is self:
return {}
ret... | [
[
1,
0,
0.0032,
0.0032,
0,
0.66,
0,
851,
0,
1,
0,
0,
851,
0,
0
],
[
1,
0,
0.0064,
0.0032,
0,
0.66,
0.0667,
632,
0,
3,
0,
0,
632,
0,
0
],
[
3,
0,
0.135,
0.2412,
0,
0... | [
"from rope.base.fscommands import _decode_data",
"from rope.base import ast, exceptions, utils",
"class PyObject(object):\n\n def __init__(self, type_):\n if type_ is None:\n type_ = self\n self.type = type_\n\n def get_attributes(self):",
" def __init__(self, type_):\n ... |
import os
class ResourceObserver(object):
"""Provides the interface for observing resources
`ResourceObserver`\s can be registered using `Project.
add_observer()`. But most of the time `FilteredResourceObserver`
should be used. `ResourceObserver`\s report all changes passed
to them and they don... | [
[
1,
0,
0.0037,
0.0037,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
3,
0,
0.1107,
0.1956,
0,
0.66,
0.25,
384,
0,
6,
0,
0,
186,
0,
5
],
[
8,
1,
0.0406,
0.048,
1,
0.8... | [
"import os",
"class ResourceObserver(object):\n \"\"\"Provides the interface for observing resources\n\n `ResourceObserver`\\s can be registered using `Project.\n add_observer()`. But most of the time `FilteredResourceObserver`\n should be used. `ResourceObserver`\\s report all changes passed\n t... |
"""A few useful functions for using rope as a library"""
import os.path
import rope.base.project
import rope.base.pycore
from rope.base import taskhandle
def path_to_resource(project, path, type=None):
"""Get the resource at path
You only need to specify `type` if `path` does not exist. It can
be eithe... | [
[
8,
0,
0.0154,
0.0154,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0308,
0.0154,
0,
0.66,
0.125,
79,
0,
1,
0,
0,
79,
0,
0
],
[
1,
0,
0.0615,
0.0154,
0,
0.66,
... | [
"\"\"\"A few useful functions for using rope as a library\"\"\"",
"import os.path",
"import rope.base.project",
"import rope.base.pycore",
"from rope.base import taskhandle",
"def path_to_resource(project, path, type=None):\n \"\"\"Get the resource at path\n\n You only need to specify `type` if `pat... |
import rope.base.evaluate
from rope.base import ast
class Arguments(object):
"""A class for evaluating parameters passed to a function
You can use the `create_arguments` factory. It handles implicit
first arguments.
"""
def __init__(self, args, scope):
self.args = args
self.sco... | [
[
1,
0,
0.0092,
0.0092,
0,
0.66,
0,
790,
0,
1,
0,
0,
790,
0,
0
],
[
1,
0,
0.0183,
0.0092,
0,
0.66,
0.1667,
632,
0,
1,
0,
0,
632,
0,
0
],
[
3,
0,
0.211,
0.3394,
0,
0... | [
"import rope.base.evaluate",
"from rope.base import ast",
"class Arguments(object):\n \"\"\"A class for evaluating parameters passed to a function\n\n You can use the `create_arguments` factory. It handles implicit\n first arguments.\n\n \"\"\"",
" \"\"\"A class for evaluating parameters passe... |
import os
import sys
from rope.base import utils
def _stdlib_path():
import distutils.sysconfig
return distutils.sysconfig.get_python_lib(standard_lib=True)
@utils.cached(1)
def standard_modules():
return python_modules() | dynload_modules()
@utils.cached(1)
def python_modules():
result = set()
... | [
[
1,
0,
0.025,
0.025,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.05,
0.025,
0,
0.66,
0.1667,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.1,
0.025,
0,
0.66,
... | [
"import os",
"import sys",
"from rope.base import utils",
"def _stdlib_path():\n import distutils.sysconfig\n return distutils.sysconfig.get_python_lib(standard_lib=True)",
" import distutils.sysconfig",
" return distutils.sysconfig.get_python_lib(standard_lib=True)",
"def standard_modules()... |
import warnings
from rope.base import exceptions
class TaskHandle(object):
def __init__(self, name='Task', interrupts=True):
"""Construct a TaskHandle
If `interrupts` is `False` the task won't be interrupted by
calling `TaskHandle.stop()`.
"""
self.name = name
s... | [
[
1,
0,
0.0075,
0.0075,
0,
0.66,
0,
358,
0,
1,
0,
0,
358,
0,
0
],
[
1,
0,
0.0226,
0.0075,
0,
0.66,
0.2,
632,
0,
1,
0,
0,
632,
0,
0
],
[
3,
0,
0.2293,
0.3759,
0,
0.6... | [
"import warnings",
"from rope.base import exceptions",
"class TaskHandle(object):\n\n def __init__(self, name='Task', interrupts=True):\n \"\"\"Construct a TaskHandle\n\n If `interrupts` is `False` the task won't be interrupted by\n calling `TaskHandle.stop()`.",
" def __init__(self... |
"""This module trys to support builtin types and functions."""
import inspect
import rope.base.evaluate
from rope.base import pynames, pyobjects, arguments, utils, ast
class BuiltinModule(pyobjects.AbstractModule):
def __init__(self, name, pycore=None, initial={}):
super(BuiltinModule, self).__init__()
... | [
[
8,
0,
0.0013,
0.0013,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0026,
0.0013,
0,
0.66,
0.0189,
878,
0,
1,
0,
0,
878,
0,
0
],
[
1,
0,
0.0052,
0.0013,
0,
0.66... | [
"\"\"\"This module trys to support builtin types and functions.\"\"\"",
"import inspect",
"import rope.base.evaluate",
"from rope.base import pynames, pyobjects, arguments, utils, ast",
"class BuiltinModule(pyobjects.AbstractModule):\n\n def __init__(self, name, pycore=None, initial={}):\n super(B... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.