- 1
 
result['first'] = False if page != 1 else True
                                    Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−109
result['first'] = False if page != 1 else True
                                    Неплохое такое выражение
−115
def _make_parser_function(name, sep=','):
    def parser_f(filepath_or_buffer,
                 sep=sep,
                 dialect=None,
                 compression=None,
                 doublequote=True,
                 escapechar=None,
                 quotechar='"',
                 quoting=csv.QUOTE_MINIMAL,
                 skipinitialspace=False,
                 lineterminator=None,
                 header='infer',
                 index_col=None,
                 names=None,
                 prefix=None,
                 skiprows=None,
                 skipfooter=None,
                 skip_footer=0,
                 na_values=None,
                 na_fvalues=None,
                 true_values=None,
                 false_values=None,
                 delimiter=None,
                 converters=None,
                 dtype=None,
                 usecols=None,
                 engine='c',
                 delim_whitespace=False,
                 as_recarray=False,
                 na_filter=True,
                 compact_ints=False,
                 use_unsigned=False,
                 low_memory=_c_parser_defaults['low_memory'],
                 buffer_lines=None,
                 warn_bad_lines=True,
                 error_bad_lines=True,
                 keep_default_na=True,
                 thousands=None,
                 comment=None,
                 decimal=b'.',
                 parse_dates=False,
                 keep_date_col=False,
                 dayfirst=False,
                 date_parser=None,
                 memory_map=False,
                 nrows=None,
                 iterator=False,
                 chunksize=None,
                 verbose=False,
                 encoding=None,
                 squeeze=False,
                 mangle_dupe_cols=True,
                 tupleize_cols=True,
                 ):
        # Alias sep -> delimiter.
        if delimiter is None:
            delimiter = sep
        kwds = dict(delimiter=delimiter,
                    engine=engine,
                    dialect=dialect,
                    compression=compression,
                    doublequote=doublequote,
                    escapechar=escapechar,
                    quotechar=quotechar,
                    quoting=quoting,
                    skipinitialspace=skipinitialspace,
                    lineterminator=lineterminator,
                    header=header,
                    index_col=index_col,
                    names=names,
                    prefix=prefix,
                    skiprows=skiprows,
                    na_values=na_values,
                    na_fvalues=na_fvalues,
                    true_values=true_values,
                    false_values=false_values,
                    keep_default_na=keep_default_na,
                    thousands=thousands,
                    comment=comment,
                    decimal=decimal,
                    parse_dates=parse_dates,
                    keep_date_col=keep_date_col,
                    dayfirst=dayfirst,
                    date_parser=date_parser,
                    nrows=nrows,
                    iterator=iterator, ....
                                    На самом деле оно в общем не такое уж и страшное потому что в питоне можно по имени аргументы в метод, но флешер в мне нервно икнул
−113
escape_cats = [cat_id for cat_id, values in cats.iteritems() if any([values[1] == supercat or cat_id == supercat for supercat in escape_supercats])]
                                    Избегание котов.
−113
user8@linux ~ $ python
Python 2.7.5 (default, Feb 10 2014, 02:34:23) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> 1-3*(math.exp(1)-2)/math.exp(1)
0.207276647028654
>>> 1-4*(1-3*(math.exp(1)-2)/math.exp(1))
0.17089341188538398
>>> 1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))
0.14553294057308008
>>> 1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))
0.1268023565615195
>>> 1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))
0.11238350406936348
>>> 1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))
0.10093196744509214
>>> 1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))
0.09161229299417073
>>> 1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))
0.0838770700582927
>>> 1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))
0.07735222935878028
>>> 1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))
0.07177324769463667
>>> 1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))
0.06694777996972334
>>> 1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))
0.06273108042387321
>>> 1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))))
0.059033793641901866
>>> 1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))))
0.05545930172957014
>>> 1-17*(1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1)))))))))))))))
0.05719187059730757
>>> 1-18*(1-17*(1-16*(1-15*(1-14*(1-13*(1-12*(1-11*(1-10*(1-9*(1-8*(1-7*(1 - 6*(1 - 5*(1-4*(1-3*(math.exp(1)-2)/math.exp(1))))))))))))))))
-0.029453670751536265
                                    
            Дано рекуррентное соотношение: x 1 = 1 e , x k = 1 − kx k−1 , k = 2, 3, 4, . . .
Напишите программу, которая вычисляет первые 15 чисел с точностью float и выводит их на экран
        
−114
cur.execute("""SELECT EXTRACT(dow from DATE %(date)s)""", {"date" : datetime})
week = cur.fetchone()
                                    Я конечно знаю, что ГК про даты это плохой тон, но такого я еще не видел.
−115
def checkio(res):
    #bruteforce LOL
    if res[0][0] == res[1][0] == res[2][0] == "X":
        return "X"
    if res[0][1] == res[1][1] == res[2][1] == "X":
        return "X"
    if res[0][2] == res[1][2] == res[2][2] == "X":
        return "X"
    if res[0][0] == res[0][1] == res[0][2] == "X":
        return "X"
    if res[1][0] == res[1][1] == res[1][2] == "X":
        return "X"  
    if res[2][0] == res[2][1] == res[2][2] == "X":
        return "X"
    if res[0][0] == res[1][1] == res[2][2] == "X":
        return "X" 
    if res[0][2] == res[1][1] == res[2][0] == "X":
        return "X"
    if res[0][0] == res[1][0] == res[2][0] == "O":
        return "O"    
    if res[0][1] == res[1][1] == res[2][1] == "O":
        return "O"
    if res[0][2] == res[1][2] == res[2][2] == "O":
        return "O"
    if res[0][0] == res[0][1] == res[0][2] == "O":
        return "O"
    if res[1][0] == res[1][1] == res[1][2] == "O":
        return "O"
        
    if res[2][0] == res[2][1] == res[2][2] == "O":
        return "O"
    if res[0][0] == res[1][1] == res[2][2] == "O":
        return "O"        
    if res[0][2] == res[1][1] == res[2][0] == "O":
        return "O"
    return "D"
                                    Определить результат игры в крестики нолики.
−109
def remove_duplicates(seq):
    seen = set()
    seen_add = seen.add
    return [x for x in seq if x not in seen and not seen_add(x)]
                                    замечательная функция, возвращающая уникальные элементы списка.
−109
if form.cleaned_data.has_key('replace_id') and type(form.cleaned_data['replace_id']) == type(32):
    ...
                                    Логично, чо
−113
def convert_get_to_post(header='HTTP_X_GET_DATA'):
    def decorator(function):
        @wraps(function)
        def wrapper(request, *args, **kwargs):
            if header in request.META:
                request.method = 'GET'
                request.GET = request.POST
            return function(request, *args, **kwargs)
        return wrapper
    return decorator
                                    Как избежать проблему с большим количеством параметров в URL при GET запросе...
−110
# количество гласных в строке
vowelsCount = lambda s: sum([1 for x in s if x in ['i','a','e','o','u']])
# Вхождение подстроки в строку
substringOccurence = lambda S,s:sum([1 for i in range(len(S) + 1 - len(s)) if S[i:i + len(s)] == s])
g = lambda S,s:'Number of times ' + substr + ' occurs is: ' + str(substringOccurence(S,s))
# первая из упорядоченных подстрок максимальной длины
alpha = lambda s:  [x for x in  
   [s[i:i + j] for j in range(len(s),0,-1)for i in range(len(s) - j + 1)]
    if x == ''.join(sorted(x))][0]
# atoi без atoi
stringToInteger = lambda s: sum([(ord(n) - ord('0')) * (10 ** i) for i,n in enumerate(s[::-1])])
                                    Питонячьи извращения для одного курса или не все однострочники одинаково полезны.