- 1
- 2
- 3
- 4
url = request.get_full_path()
if 'show_error' in url:
show_param = url.split('?show_error=')
error = show_param[1]
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−428
url = request.get_full_path()
if 'show_error' in url:
show_param = url.split('?show_error=')
error = show_param[1]
Кусок кода из Django проекта
Взяли индуса на работу. Вот так он достает GET параметры
−94
#*тут определение факториала*
fac_missing_end = factorial(100)/1000000000000000000000000
#there are 134 digits when you take off the zeroes at the end
sum_of_digits = 0
recent_digit = fac_missing_end%10
new_fac = fac_missing_end/10
sum_of_digits = sum_of_digits + recent_digit
recent_digit = new_fac%10
new_fac = new_fac/10
sum_of_digits = sum_of_digits + recent_digit
recent_digit = new_fac%10
new_fac = new_fac/10
sum_of_digits = sum_of_digits + recent_digit
recent_digit = new_fac%10
new_fac = new_fac/10
sum_of_digits = sum_of_digits + recent_digit
# еще пару десятков строк такого говна
print sum_of_digits
http://projecteuler.net/problem=20
http://projecteuler.net/thread=20;page=8
>This is ridiculous, but it worked instantaneously
Первый шаг к решению проблемы — признать что у тебя есть проблема.
−98
# TODO: fix this hell
def pretty_print(w, p):
w = truncate(w)
p = truncate(p)
my_matrix = zip(p, w)
print "\n".join(["\t\t".join(["\t".join(map(str, r)) for r in t]) for t in my_matrix])
# TODO: and this
def truncate(m):
for i in range(len(m)):
for j in range(len(m[0])):
if(len(str(m[i][j])) > 5):
m[i][j] = "%.3f" % m[i][j]
return m
−92
def success_operation(operation):
"""помечаем операцию как оплаченную"""
#получаем коллбэк и выполняем его
if operation.close_callback:
path, callback_name, params =\
(lambda v, f: (len(v) > 1 and f(v[0], v[1])) or f(v[0]))(
(operation.close_callback or '').split('|'),
lambda n, k = None:
(lambda n: (lambda l: ['.'.join(l[0:len(l) - 1]) or 'app.billing.callbacks'] + [l[len(l) - 1]])(
n.split('.'))
)(n) + \
[(lambda k: not (k is None) and reduce(
lambda h, t: (lambda a, p: a.setdefault(*p) and a)(
h,
(lambda l: (l[0].strip(), l[1].strip()))(t.split('='))
),
k.split(','),
{})
)(k) or {}])
Человек правильно живет, но зря.
−99
referer = ''
if 'HTTP_REFERER' in request.META :
referer = request.META['HTTP_REFERER']
И подобного кода в проекте тонны...
−100
def del_space_both(t):
return del_space_end(del_space_begin(t))
def del_space_begin(text):
if len(text):
while text[:1] == ' ': text = text[1:]
return text
def del_space_end(text):
if len(text):
while text[-1:] == ' ': text = text[:-1]
return text
религия не позволяет использовать strip(), lstrip() и rstrip
−97
for digest in li:
s = 1
i = 0
j = 1
while i <= 4:
s = int(digest[i:j]) * s
i += 1
j += 1
li2.append(s)
Вычисление произведения пяти чисел
li = список строк вида "01234"
−86
def password_generator(count = 8):
import random
i = 0
password = ''
symbols = ['q','w','e','r','t','y','u','i','o','p','s','a','d','f','g','h','j','k','l','z','x','c','v','b','n','m','1','2','3','4','5','6','7','8','9','0']
while i<count:
tempsymbol = ''
tempsymbol += random.choice(symbols)
temp = random.randint(0,1)
if temp == 1:
password += tempsymbol.upper()
else:
password += tempsymbol
i += 1
return password
Белорусские питонисты генерируют пароль.
−89
columns = [col for col in self.load_column_data()['columns']]
Вот так мы копируем списки.
−90
def runRidor():
isDirty = 0
#Except (DebugSize <= 14) and (ImageVersion <= 760) and (VirtualSize2 > 992) and (ExportSize <= 80.5) => isDirty = 1 (1702.0/16.0) [855.0/5.0]
if input.DebugSize <= 14 and input.ImageVersion <= 760 and input.VirtualSize2 > 992 and input.ExportSize <= 80.5:
isDirty = 1
#Except (DebugSize <= 14) and (ImageVersion <= 4525) and (ExportSize <= 198.5) and (ResourceSize <= 37532) and (VirtualSize2 <= 6) and (ResourceSize <= 7348) and (ResourceSize > 1773) => isDirty = 1 (106.0/0.0) [48.0/0.0]
elif input.DebugSize <= 14 and input.ImageVersion <= 4525 and input.ExportSize <= 198.5 and input.ResourceSize <= 7348 and input.VirtualSize2 <=6 and input.ResourceSize > 1773:
isDirty = 1
#Except (DebugSize <= 14) and (ImageVersion <= 4950) and (ExportSize <= 192) and (IatRVA > 256) and (VirtualSize2 > 42) and (ExportSize <= 56) and (NumberOfSections > 3.5) => isDirty = 1 (193.0/0.0) [91.0/0.0]
elif input.DebugSize <= 14 and input.ImageVersion <= 4950 and input.ExportSize <= 56 and input.IatRVA > 256 and input.VirtualSize2 > 42 and input.NumberOfSections > 3.5:
isDirty = 1
#Except (DebugSize <= 14) and (ImageVersion <= 4950) and (VirtualSize2 <= 6) and (ResourceSize <= 37532) and (ResourceSize <= 17302) => isDirty = 1 (388.0/0.0) [216.0/7.0]
elif input.DebugSize <= 14 and input.ImageVersion <= 4950 and input.VirtualSize2 <= 6 and input.ResourceSize > 17302:
isDirty = 1
#Except (DebugSize <= 14) and (NumberOfSections > 2.5) and (ResourceSize > 1776) and (IatRVA <= 6144) and (ExportSize <= 219.5) and (VirtualSize2 > 2410) and (VirtualSize2 <= 61224) => isDirty = 1 (238.0/0.0) [116.0/0.0]
elif input.DebugSize <= 14 and input.NumberOfSections >= 2.5 and input.ResourceSize <= 1776 and input.IatRVA <= 6144 and input.ExportSize <= 219.5 and input.VirtualSize2 > 2410 and input.VirtualSize2 <= 61224:
isDirty = 1
Пример того, как не надо писать на питоне, показывает Adobe. Полная версия: http://voxel.dl.sourceforge.net/project/malclassifier.adobe/AdobeMalwareClassifier.py