1. Python / Говнокод #16390

    −94

    1. 1
    list(zip_longest(*[iter(('0'+str(bin(int(time.time())))[2:]).replace('0', '_').replace('1', '*'))]*4))

    увидел у в скрипте на подобии archey3

    rob_vigna, 20 Июля 2014

    Комментарии (18)
  2. Python / Говнокод #16358

    −422

    1. 1
    2. 2
    3. 3
    4. 4
    import math
    print math.pow(2,64) //1.84467440737e+19
    print pow(2,64)         //18446744073709551616
    print 2**64               //18446744073709551616

    http://ideone.com/kmGrBa
    http://ideone.com/otSgCP

    Говно в обоих версиях калькулятора.

    3.14159265, 16 Июля 2014

    Комментарии (58)
  3. Python / Говнокод #16298

    −97

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    def load_library():
        requests = []
        class Handler(object):
            pass
        Handler.errors = 0
        def handler(request):
            print "failed to load: %s" % request.url
            Handler.errors += 1
        for node in res:
            for url in filter(lambda x: x, map(node.prop, names)):
                requests.append(grequests.get(url))
        gmap(tuple(requests), exception_handler = handler)
        print "total failures: %s" % Handler.errors

    Ля-ля-ля, замыкания!

    wvxvw, 10 Июля 2014

    Комментарии (211)
  4. Python / Говнокод #16250

    −96

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    import random
    
    while 0<1:
        inn_d=str(random.randint(100000000,999999999))
        a=int(inn_d[:1])*2
        b=int(inn_d[1:2])*4
        c=int(inn_d[2:3])*10
        d=int(inn_d[3:4])*3
        e=int(inn_d[4:5])*5
        f=int(inn_d[5:6])*9
        g=int(inn_d[6:7])*4
        l=int(inn_d[7:8])*6
        m=int(inn_d[8:9])*8
        x=a+b+c+d+e+f+g+l+m
        y=x%11
        if y%11==10:
            y=0
        print str(inn_d)+str(y)

    Такой вот генератор ИННов

    pl7ofit, 28 Июня 2014

    Комментарии (11)
  5. Python / Говнокод #16203

    −100

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #Было
    def extract_brand(x):
                    x = x[0].lower()
                    for brand in brands:
                        if x.count(brand):
                            return brand
    il.brand_out = extract_brand
    
    #Стало после кодревью
    il.brand_in = lambda x: [brand for brand in brands if brand.lower() in x[0].lower()]

    Кто то смог прочитать второй вариант?

    kyzi007, 22 Июня 2014

    Комментарии (90)
  6. Python / Говнокод #16145

    −99

    1. 1
    2. 2
    3. 3
    def dict_to_tuple(d):
        """Converts an ordered dict into a tuple."""
        return tuple(dict_to_list(d))

    hugr, 11 Июня 2014

    Комментарии (15)
  7. Python / Говнокод #16142

    −97

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    jstemplate = ''
    jstemplate += '$(document).ready(function () {'
    jstemplate += '    $(document).on("click", ".im", function () {'
    jstemplate += '        if ($(this).attr("src") != "") {'
    jstemplate += '            $("#im").attr("src", $(this).attr("src"));'
    jstemplate += '            $("#FixedBlack").show().fadeTo(200, 1);'
    jstemplate += '            $("#im").show().fadeTo(0.5, 1);'
    jstemplate += '        }'
    jstemplate += '    });'
    jstemplate += '    $(document).on("click", "#FixedBlack", function () {'
    jstemplate += '        $("#im").hide();'
    jstemplate += '        $("#FixedBlack").stop(true).fadeTo(200, 0, function () {'
    jstemplate += '            $("#FixedBlack").hide();'
    jstemplate += '        });'
    jstemplate += '    });'
    jstemplate += '});'

    Это вместо того, чтобы положить шаблон в файл и спокойно прочитать его в переменную. nuff said.

    Bispja, 10 Июня 2014

    Комментарии (44)
  8. Python / Говнокод #16135

    −92

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    # @models.permalink
        def get_absolute_url(self):
            def urls_r(urlresolver, prefix = ''):
                urllist = []
                urlname = []
                for i in urlresolver:
                    if str(type(i)) == "<class 'django.core.urlresolvers.RegexURLResolver'>":
                        url_return = urls_r(i.url_patterns, i.regex.pattern)
                        urllist += url_return[0]
                        urlname += url_return[1]
                    else:
                        urllist.append(prefix + i.regex.pattern[1:])
                        urlname.append(i.name)
                return urllist, urlname
    
            from bizon.urls import urlpatterns
            from code.core.urls import code
    
            urllist, urlname = urls_r(urlpatterns)
    
            url = ''
            try:
                url = urllist[urlname.index('news_show')]
            except:
                print sys.exc_info()
    
            absolute_url = url.replace('^', '/').replace('(%s)' %code, '%s').replace('(\\d+)', '%d').replace('$', '') %(self.language, self.pk)
            return absolute_url

    сюрпризы в коде проектов от бывших коллег, феерией было видеть рядом с этим кодом маленькую функцию:
    def get_link(self):
    return '/ru/news/information/new/%d/' % (self.id)

    oxymoron42, 09 Июня 2014

    Комментарии (4)
  9. Python / Говнокод #16069

    −94

    1. 1
    l.category_out = lambda x: filter(lambda y: y != u'»', x)

    kyzi007, 28 Мая 2014

    Комментарии (15)
  10. Python / Говнокод #15934

    −96

    1. 1
    удалено

    удалено

    dunmaksim, 07 Мая 2014

    Комментарии (15)