code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Python |
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Python |
__version__ = "1.0c2"
| Python |
#!/usr/bin/python2.4
#
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | Python |
#!/usr/bin/python2.4
#
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | Python |
"""
iri2uri
Converts an IRI to a URI.
"""
__author__ = "Joe Gregorio (joe@bitworking.org)"
__copyright__ = "Copyright 2006, Joe Gregorio"
__contributors__ = []
__version__ = "1.0.0"
__license__ = "MIT"
__history__ = """
"""
import urlparse
# Convert an IRI to a URI following the rules in RFC 3987
#
# The characte... | Python |
from __future__ import generators
"""
httplib2
A caching http interface that supports ETags and gzip
to conserve bandwidth.
Requires Python 2.3 or later
Changelog:
2007-08-18, Rick: Modified so it's able to use a socks proxy if needed.
"""
__author__ = "Joe Gregorio (joe@bitworking.org)"
__copyright__ = "Copyright... | Python |
"""SocksiPy - Python SOCKS module.
Version 1.00
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
... | Python |
import Cookie
import datetime
import time
import email.utils
import calendar
import base64
import hashlib
import hmac
import re
import logging
# Ripped from the Tornado Framework's web.py
# http://github.com/facebook/tornado/commit/39ac6d169a36a54bb1f6b9bf1fdebb5c9da96e09
#
# Tornado is licensed under the Apache Licen... | Python |
# This is the version of this source code.
manual_verstr = "1.5"
auto_build_num = "211"
verstr = manual_verstr + "." + auto_build_num
try:
from pyutil.version_class import Version as pyutil_Version
__version__ = pyutil_Version(verstr)
except (ImportError, ValueError):
# Maybe there is no pyutil insta... | Python |
"""
The MIT License
Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the ... | Python |
"""
The MIT License
Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the ... | Python |
"""
The MIT License
Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the ... | Python |
# Early, and incomplete implementation of -04.
#
import re
import urllib
RESERVED = ":/?#[]@!$&'()*+,;="
OPERATOR = "+./;?|!@"
EXPLODE = "*+"
MODIFIER = ":^"
TEMPLATE = re.compile(r"{(?P<operator>[\+\./;\?|!@])?(?P<varlist>[^}]+)}", re.UNICODE)
VAR = re.compile(r"^(?P<varname>[^=\+\*:\^]+)((?P<explode>[\+\*])|(?P<part... | Python |
def foobar():
print 'yes'
foobar()
| Python |
print 4
| Python |
for i in range(10):
print i
| Python |
class X: pass
| Python |
import goog.math as gm
v0 = gm.Vec2(10, 12)
print "ctor", v0
v1 = gm.Vec2.randomUnit()
print "randomunit", gm.nearlyEquals(v1.magnitude(), 1.0);
v2 = gm.Vec2.random()
# todo; attr access
#print v2.x >= -1 and v2.x <= 1, v2.y >= -1 and v2.y <= 1
v3 = gm.Vec2.fromCoordinate(gm.Coordinate(4, 5))
print "fromcoord", v3
... | Python |
import goog.json
print goog.json.parse
# random sample from json.org
obj = goog.json.parse("""
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortA... | Python |
from goog.json import parse as jparse
print jparse('''
{"x":5, "y":6, "z":[3.1, 4.7, 5.6]}
''')
| Python |
import goog.math as gm
c1 = gm.Coordinate()
c2 = gm.Coordinate(1)
c3 = gm.Coordinate(1, 2)
print c1.toString()
print c2.toString()
print c3.toString()
c4 = gm.Coordinate(1, 2)
c5 = gm.Coordinate(3, 4)
print gm.Coordinate.equals(c3, c4)
print gm.Coordinate.equals(c3, c5)
c6 = c4.clone()
c7 = c6.clone()
print gm.Coordi... | Python |
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
| Python |
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... | Python |
x = 3.14e159
| Python |
x = -15921590215012591L
| Python |
(-124561-1) & 0200000000
| Python |
x = 314159.
| Python |
x = "doesn't "shrink", does it"
| Python |
0xdeadc0de & 012345
| Python |
print """wee waa
woo wii"""
| Python |
-1*1/1+1*1//1 - ---1**1
| Python |
x = 3E123
| Python |
x = 3e14159
| Python |
0xff <= 255
| Python |
import sys, time
x = sys.modules['time'].time()
| Python |
x+y = 3e-1230
| Python |
def d01v_(a=1, *k, **w): pass
| Python |
0b01 <= 255
| Python |
y = ur"abc" + Ur"ABC" + uR"ABC" + UR"ABC"
| Python |
x = .314159
| Python |
if False:
# NL
True = False # NEWLINE
| Python |
def k(x):
x += 2
x += 5
| Python |
@staticmethod
def foo(x,y): pass
| Python |
if 1 < 1 > 1 == 1 >= 5 <= 0x15 <= 0x12 != 1 and 5 in 1 not in 1 is 1 or 5 is not 1: pass
| Python |
x = 1//1*1/5*12%0x12
| Python |
0xFF & 0x15 | 1234
| Python |
x = 1 << 1 >> 5
| Python |
a = r'''this is some
more stuff
| Python |
x = u'abc' + U'ABC'
| Python |
x = 0xfffffffffff
| Python |
0xdeadbeef != -1
| Python |
2134568 != 01231515
| Python |
wee = """this is some
stuff and
| Python |
def d22(a, b, c=2, d=2, *k): pass
| Python |
~1 ^ 1 & 1 |1 ^ -1
| Python |
0o123 <= 0123
| Python |
x = ur'abc' + Ur'ABC' + uR'ABC' + UR'ABC'
| Python |
x = '"'; y = "'"
| Python |
1 + 1
| Python |
x = 123141242151251616110l
| Python |
x = ''; y = ""
| Python |
x = 1 - y + 15 - 01 + 0x124 + z + a[5]
| Python |
01234567 > ~0x15
| Python |
x = 3.14159
| Python |
def f():
if True:
if False:
x =3
y = 4
return
return 19
| Python |
x = 0L
| Python |
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 ... | Python |
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
... | Python |
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... | Python |
x = [0, 1, 2]
print x
x.insert(2, x.pop(0))
print x
| Python |
x = ('OK',)
print(x[0])
| Python |
import pkga.pkgb.modc as c_me
print c_me.stuff
print c_me.things
| Python |
x=4
x|=1
print x
| Python |
# 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(... | Python |
print("O"+"K")
| Python |
if None is None:
print "OK"
| Python |
def f():
y = 0
while y == 0:
y += 1
yield y
for i in f():
print i
| Python |
print False or False
| Python |
class C:
def __init__(self, data):
self.data = data
def pr(self):
print self.data
C("OK").pr()
| Python |
if not "?" in "xyz": print "OK"
| Python |
a = b,c = 1,2
print a[0]
print a[1]
print b
print c
| Python |
x = 'OK',1
print x[0]
| Python |
if 0 == 1:
print "X"
else:
print "OK"
| Python |
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__
| Python |
print 3*7
| Python |
print long
print long(3.0)
print long(3)
print type(long(3.0))
print type(long(3))
| Python |
print [1,2,3].index(3)
| Python |
print slice(1)
| Python |
def wee(waa, woo=True, wii=False):
print waa, woo, wii
wee("OK")
| Python |
def test(x,y):
return x+y
r = test(3,5)
print r
| Python |
class X:
x = 4
x = X()
stuff = x.x
print stuff
things = X.x
print things
| Python |
# 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
| Python |
def a():
x = "OK"
print x
del x
print "after"
a()
| Python |
class X: pass
print repr(X())
print str(X())
| Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.