1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
def func(foo, bar, *args, **kwargs):
pass
mydict = dict()
mylist = list(mydict)
class c():
attr = 5
another_comprehended_list = [item.attr for item in [c(), c(), c()]]
comprehended_list = [x for x in [1, 2, 3] if x in ('a')]
print(x)
def func(**kwargs):
for item in kwargs.iterkeys():
print(item)
return kwargs
def yieldTest():
yield "foo"
def my_func():
my_var_04 = 5
my_var_01 = 1
my_var_07 = 12
my_var_07 = 12
my_var_07 = 12
more_vars = 2
my_var_02 = 2
my_var_03 = 3
class cls():
def myfunc(self):
some_var = my_func
def another(self):
print(self)
new_threads = cls()
try:
known_threads = {line.strip() for line in ["foo"] if line.strip()}
except IOError:
pass
known_threads = set()
# Remove threads already in the cache so we can write the new ones only.
new_threads = new_threads - known_threads
import os
def ASDF(arg, arg2):
arg = arg2
print(arg2)
print(ASDF())
a = a and a
a = a or b
class some_class(foo, bar):
def __init__(self):
pass
attr1 = 3
attr2 = 5
attr3 = 'str'
argarg = 2
some_instance = some_class()
some_instance.attr1
some_instance.attr2
some_instance.some_method().foobar
some_instance.some_method(some_arg, some_arg2).second_attribute
some_instance \
. attr1 \
.funcfunc(argarg, arg2arg) \
.foo
#comment
"""
multiline comment
foo
bar
"""
import sys
import random
import PyQt4.QtCore
import bisect
bisect.bisect_right()
def returns_int(param):
return 5
def returns_str(param):
return 'str'
def returns_list(param): return [];
foo = returns_list()
bar = 'test'
foo = returns_int()
s = returns_str()
l = returns_list()
def simple_func(foo):
""" usage comment, bla, param:foo"""
pass
copied = simple_func
def function(foo):
""" docstring
more
more more
>>> test
>>> test
"""
return foo
async def fonc(x, y, z):
a = await z
try:
pass
except Exception as e:
print(e)
def func(foo, bar, baz, bang, foobang, foobar, foobazbar, foobazbarbang):
return foobang
import asynchat
obj = asynchat.async_chat()
obj.collect_incoming_data()
import _winreg
_winreg.CreateKey()
import binhex
binhex.hexbin()
if foobazbar < 5:
pass
func(sys)
simple_func()
def func_without_param():
pass
return [(lambda foo: foo) for fdlksh in [1, 2, 3]]
func_without_param()
def another_function(param):
return [3 for x in param]
a = 5
bar = a == a
a != a
a < a
a <= a
a > a
a < a < a
a >= a
a is a
a is not a
a not in a
a in a
a = a + 1
a = a - 1
a = a * 1
a = a / 1
a = a // 1
a = a % 1
a = a ^ 1
a = a & 1
a = a | 1
a = a ** 1
a = a >> 1
a = a << 1
a = a @ 1
a = not a
a = +a
a = -a
a = ~a
a = b[1:2:3][2]
extended = a[1:2, 2:3]
i += 3
i += j
3 if 5 < 7 else 4
from random import random
random(foo=3)
a = lambda x: x**2
@staticmethod
@classmethod
def genfunc():
yield foo
for target1, target2 in some_dict.iteritems():
print(target1, target2)
pi = 3.1415
foo = 1, 2
bar = (1, 2)
with open('f') as foo:
pass
global IMAGLOBALVARIABLE
IMAGLOBALVARIABLE = 0
try:
a = 3 / 0
except ZeroDivisionError as err:
raise ValueError
else:
do_something()
finally:
BAM
if 3 and 5:
pass
for i in xrange(20):
pass
while True:
break
continue
del foo
import random
random.random(3, 5)
somelist = [1, 2, 3, 4, 5]
somedict = { 'key1' : 'value1', key2: value2 }
somelist[...]
somelist[1:]
somelist[:20]
somelist[1:20]
somelist[1:20:2]
class bar(parent):
pass
if foo in bar and 3 < 5:
pass
a = [x*2 for x in xrange(20)]
variable.variable2.variable3 = 15
def function(param1, param2, param3, *paramstar, **paramdstar):
pass
return param1 * param2
assert False
if not 3:
pass
if 3 * 5 == 7:
pass
|