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

    −178

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    cursor.execute(bla)
    count = cursor.fetchone()
    
    if count[0] > 0 or True:
        cursor.execute(bla)

    ragzovkii, 21 Февраля 2012

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

    −102

    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
    def to_sk_pzd(text):
        result = ''
        for char in text:
            for bit in str(bin(ord(char))):
                if bit == '0':
                    result += 'сука'
                elif bit == '1':
                    result += 'пиздец'
        return result
    
    print to_sk_pzd('чо нада?')
    
    # Output:
    # сукапиздецпиздецпиздецпиздецсукапиздецпиздецпиздецсукапиздецпиздецпиздецсукапиздецпиздецпиздецсукасукапиздецсукасукасукасукасукасукапиздецпиздецпиздецсукапиздецпиздецсукапиздецсукапиздецпиздецпиздецсукасукасукасукасукасукапиздецпиздецпиздецсукасукапиздецсукасукасукапиздецпиздецпиздецсукасукасукасукасукасукапиздецпиздецпиздецпиздецпиздецпиздец

    гопник-байт-encoding

    Nyashka, 18 Января 2012

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

    −87

    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
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    #!/usr/bin/python
    import itertools, math, os, random, re, sys
    random.seed (1234)
    
    while True:
            s = sys.stdin.readline ().strip ()
            if s == '':
                    s = sys.stdin.readline ().strip ()
                    if s == '':
                            break
            t = sys.stdin.readline ()
            r = sys.stdin.readline ()
            s = [c for c in s]
            t = [c for c in t]
            r = [c for c in r]
            s.sort ()
            t.sort ()
            r.sort ()
            ok = True
            for c in r:
                    if len (s) > 0 and c == s[0]:
                            s = s[1:]
                    elif len (t) > 0 and c == t[0]:
                            t = t[1:]
                    else:
                            ok = False
            ok = ok and len (s) == 0 and len (t) == 0
            if ok:
                    print 'YES'
            else:
                    print 'NO'
    
    #Люди делают так:
    #a, b, c = (raw_input() for i in range(3))
    #print 'YES' if sorted(a + b) == sorted(c) else 'NO'

    Задача такая: даны три строки: a, b и c
    проверить что третья может быть получена из двух других преремешиванием

    Источник:
    codeforces, Codeforces beta 101 round, 1018183

    VisualPaul, 08 Января 2012

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

    −89

    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
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    def getResidueList():
    	resList = []
    	resList.append("366")
    	resList.append("367")
    	resList.append("368")
    	resList.append("369")
    	resList.append("370")
    	resList.append("371")
    	resList.append("372")
    	resList.append("373")
    	resList.append("374")
    	resList.append("375")
    	resList.append("376")
    	resList.append("377")
    	resList.append("378")
    	resList.append("379")
    	resList.append("380")
    	resList.append("381")
    	resList.append("382")
    	resList.append("383")
    	resList.append("384")
    	resList.append("385")
    	resList.append("386")
    
           .... и так далее ... 
    
    	resList.append("405")
    	resList.append("406")
    	resList.append("407")
    	resList.append("408")
    	resList.append("409")
    	resList.append("410")
    	resList.append("411")
    	resList.append("412")
    	resList.append("413")
    	resList.append("414")
    
           ... и так далее ....
    
            resList.append("585")
    	resList.append("586")
    	resList.append("587")
    	resList.append("588")
    	resList.append("589")
    
    	return resList

    Циклы? Не, не слышал

    denis90, 07 Января 2012

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

    −86

    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
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    def search_with_city(obj1, obj2, obj3):
        print '------------Search by latitude, longitude and city------------'
        list1 = []
        list_new = []
        while True:
            line = file_airport.readline().lower()
            if obj3 in line:
                Str_file = ''.join(line)
                List_file2 = Str_file.split(',')
                if obj3 in List_file2[7]:
                    list1.append(List_file2)
                    for item in list1:
                        item.append(sqrt((float(item[11]) - float(obj1))**2 + (float(item[12]) - float(obj2))**2))
                        list_new = sorted(list1, key = lambda x: x[-1], reverse = False)
                    config = yaml.load(open('findairport.conf'))
                    outs = config['output']
                for List_file in list_new:
                    if List_file2[3] != List_file[3]:
                        for out in outs:
                            out = out % dict(airportcode = str(List_file[0]).upper(), distance = List_file[-1],\
                                airportname = str(List_file[13]).title(),  sa = str(List_file[8]).title(), street = str(List_file[10]).title(),\
                                city = str(List_file[7]).title(), state = str(List_file[5]).upper(), zip = List_file[3],\
                                country = str(List_file[2]).upper(), lat = str(List_file[11]), lon = str(List_file[12]+'\n'))
                            print out
            if not line:
                break
        try:
            if not obj1 in line and not obj2 in line and not obj3 in line:
                print 'Nothing more is been found'
        except:
            pass
        else:
            pass
        file_airport.seek(0)

    PHP'шники наступают! :)

    stalk, 14 Декабря 2011

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

    −89

    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
    def get_caller_module_dict(levels):
        try:
            raise RuntimeError
        except RuntimeError:
            e,b,t = sys.exc_info()
            f = t.tb_frame
            while levels > 0:
                f = f.f_back                   
                levels -= 1
            ldict = f.f_globals.copy()
            if f.f_globals != f.f_locals:
                ldict.update(f.f_locals)
    
            return ldict

    cxielamiko, 08 Декабря 2011

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

    −88

    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
    # класс ЧегоТоТамПарсер(object):
    
        def _get_images(self, soup, basedomain):
            soup = soup.get_soup()
            fb_images = soup.findAll(name="meta", attrs={
                "property": lambda property: property and property.lower() == "og:image"})
            images = (soup.body or soup).findAll(name="img", src=True)
            get_source = lambda img: img.get("content") \
                                        if img.get("content", None) \
                                        else img.get("src") \
                                        if img.get("src").startswith("http://") \
                                        else "http://"+img.get("src").lstrip("/") \
                                        if img.get("src").startswith("//") \
                                        else urljoin("http://"+basedomain, img.get("src").lstrip("/"))
            return list(set(map(get_source, fb_images + images)))
    
        def get_images(self):
            try:
                if self.basedomain:
                    return self._get_images(self.soup, self.basedomain)
                return []
            except URLError:
                return []

    над этим работало коллективное бессознательное

    nelson, 23 Ноября 2011

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

    −85

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    TEMPLATES = ( # {'s': 0, 'm': 1, 'l': 2, 'xl': 3, 'xxl': 4}
                    ((1, 0), _("1-z")),      ((1, 1), _("1-z-a")),
                    ((1, 2), _("1-z-a-p1")), ((2, 0), _("2-z")),
                    ((2, 1), _("2-z-a")),    ((2, 2), _("2-z-a-p2")),
                    ((2, 3), _("2-z-a-p3")), ((3, 0), _("3-z")),
                    ((3, 1), _("3-z-a")),    ((3, 2), _("3-z-a-p1")),
                    ((4, 0), _("4-z")),      ((4, 1), _("4-z-a")),
                    ((4, 2), _("4-z-a-p3")), ((4, 3), _("4-z-p3")),
                    ((4, 4), _("4-p3")),)

    это константа из описания класса формы, если кто-то еще не догадался

    nelson, 23 Ноября 2011

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

    −100

    1. 1
    2. 2
    3. 3
    4. 4
    class SomeThing(object)
        def _get_value(self):
            return #return some value
        get_value = property(_get_value)

    Декораторы? не не слышал.

    Zapix, 23 Ноября 2011

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

    −85

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    def __getattr__(self,name):
            if name == '_creator':
                 return 'Article'
            else:
                 raise AttributeError

    H1D, 22 Ноября 2011

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