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

    −1

    1. 1
    https://stackoverflow.com/questions/51521158/in-python-why-does-0xbin-return-false

    Свежий обосрамс питона

    syoma, 26 Июля 2018

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

    0

    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
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    #-*-coding:utf8;-*-
    
    combinators = {
       'I': lambda x: x if len(x) <= 1 else calc(x[1:]),
       'K': lambda x: x if len(x) <= 2 else calc((x[1],) + x[3:]),
       'W': lambda x: x if len(x) <= 2 else calc(x[1:3] + x[2:]),
       'S': lambda x: x if len(x) <= 3 else calc((x[1], x[3], (x[2], x[3])) + x[4:]),
       'B': lambda x: x if len(x) <= 3 else calc((x[1], (x[2], x[3])) + x[4:]),
       'C': lambda x: x if len(x) <= 3 else calc((x[1], x[3], x[2]) + x[4:]),
       'U': lambda x: x if len(x) <= 2 else calc((x[2], (x[1], x[1], x[2])) + x[3:]),
       'Y': lambda x: x if len(x) <= 1 else calc(('S',('K',('S','I','I')),('S',('S',('K','S'),'K'),('K',('S','I','I')))) + x[2:])
    }
    
    def calc(x):
        def f(x, top = False):
            if type(x) is not tuple or len(x) == 0:
                return x
            if top:
                while type(x[0]) is tuple:
                    x = x[0] + x[1:]
            else:
                if type(x[0]) is tuple:
                    return (calc(x[0]),) + f(x[1:])
            print(termrepr(x))
            input('Press Enter...')
            return combinators.get(x[0], lambda _: (x[0],) + f(x[1:]))(x)
    
        return f(x, True)
    
    def parse(s):
        def f(s, n):
            res = ()
            i = n
            while i < len(s):
                if s[i] == '(':
                    t, j = f(s, i + 1)
                    res += (t,)
                    i = j - 1
                elif s[i] == ')':
                    return (res, i + 1)
                else:
                    res += (s[i],)
                i += 1
            return (res, i)
            
        return f(s, 0)[0]
    
    def termrepr(x):
        if len(x) == 0:
            return ''
        if type(x[0]) is tuple:
            return '(' + termrepr(x[0]) + ')' + termrepr(x[1:])
        else:
            return x[0] + termrepr(x[1:])
    
    print('>> ', end = '')
    while True:
        print(termrepr(calc(parse(input()))))
        print('\n>> ', end = '')

    Я перепесал #24129:

    >> BUGURT
    BUGURT
    Press Enter...
    U(GU)RT
    Press Enter...
    R((GU)(GU)R)T
    Press Enter...
    GU(GU)R
    Press Enter...
    U(GU)R
    Press Enter...
    R((GU)(GU)R)
    Press Enter...
    GU(GU)R
    Press Enter...
    U(GU)R
    Press Enter...

    666_N33D135, 24 Июля 2018

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

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    import re
    
    brabrebrized = lambda s, repl = r"бр\1": (
        re.sub(
            "[йцкнгшщзхъфвпрлджчсмтьб]+([аеёиоуыэюя])",
            repl,
            s,
            flags = re.IGNORECASE
        )
    )

    Я ебрабрубря и брабрибрал брабрибраброр бребров. брибрер:
    брибрит брёбра бра брабробре,
    бробрит ябра в абребробре.
    брибрия! брибрия!
    бря брабрубра брибряя!

    666_N33D135, 09 Июля 2018

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

    0

    1. 1
    ('%s'%().__class__)[bool([()])<<(bool([()])<<bool({()}))]+('%s'%bool([{}]))[(bool([()])<<(bool({()})))+(bool([[]]))]+('%s'%None)[bool([()])<<bool({()})]+('%s'%{}.__class__)[bool([()])<<(bool([()])+(bool([[]])<<bool({()})))]+('%s'%None)[bool([])<<bool({()})]+('%s'%().__class__)[19%10]+('%s'%{}.__class__)[bool([()])<<(bool([()])+(bool([[]])<<bool({()})))]+('%s'%bool([]))[bool([()])<<(bool([()])<<bool({()}))]+('%s'%[].__class__)[(bool([()])+(bool([()])<<(bool([[]])<<bool({()}))))*(bool([[]])<<bool({()}))]

    skynv, 28 Июня 2018

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

    +1

    1. 1
    2. 2
    def __repr__(self) -> str:
            return f"<User{return ', inactive!' if not self.active else ''} #{self.id} ({self.username}/{self.email})>"

    Когда очень хочется использовать красивый f"{ormat}" для строки, но модель БД становится все сложнее...

    saber-nyan, 08 Июня 2018

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

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Какой есть аналог класса для данных?
    
    class Record():
        pass
    
    r = Record()
    r. asd = 1
    
    Заебало класс объявлять, неужели для такого элементарного случая ничего не придумали?

    syoma, 25 Мая 2018

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

    −3

    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
    from random import choice
     
    noun = ['пони', 'анус', 'синхрофазатрон', 'погромист', 'хуй', 'шланг', 'гцц', 'соснолька', 'хуита', 'говно', 'питушня', 'лалка', 'питон', 'енот', 'ватник', 'пидорашка', 'шиндос', 'линупс', 'жопа', 'дед мороз']
    verb = ['срёт', 'падает', 'бесит', 'пиздит', 'летает', 'сосёт', 'бегает']
    adj = ['сраный', 'ёбаный', 'розовый', 'коричневый', 'охуенный', 'пиздатый', 'тупой', 'ебучий', '']
     
    templates = [
        [adj, noun, verb],
        [adj, noun],
        [noun, ['говно']],
        [['У тебя'], adj, noun, verb],
        [['У тебя'], adj, noun],
        [['Какого хуя'], adj, noun, verb, ['\b?']],
        [['Почему'], noun, verb, ['\b?']],
        [['Что такое'], noun, ['\b?']],
        [adj, noun, verb, 'и', verb],
        [noun, verb, ['\b, a'], noun, verb],
    ]
     
    bububu = lambda: (lambda s: s[0].capitalize() + s[1:] + (choice('.!?') if s[-1] not in '.!?' else ''))(' '.join(i for i in map(choice, choice(templates)) if i))
     
     
    for _ in range(30):
        print(bububu())

    https://ideone.com/oOwyzI
    Просто от неча делать...

    666_N33D135, 24 Мая 2018

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

    0

    1. 1
    Прыщеговно

    Explanation: The issue stemmed from two issues one in normpath and the other in os.path.join. It turns out that when normpath (or abspath) gets an absolute path starting with a single slash or 3+ slashes, the result would have a single slash. However, if the input had exactly two leading slashes the output will retain them. This behavior conforms to an obscore passage in the POSIX standard (last paragraph):

    A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.

    normpath и abspath из os.path

    syoma, 23 Мая 2018

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

    +1

    1. 1
    2. 2
    In [42]: os.path.join(r'c:\asd', r'c:\www')
    Out[42]: 'c:\\www'

    Нахуя???

    syoma, 23 Мая 2018

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

    0

    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
    def sql_select_filter(sql, flt, order=None, limit=None, offset=None, group_by=None, lock=None, withSelectWrapper=True):
        if withSelectWrapper and group_by is None:
            if re.search(r'^\s*select\s+', sql, flags=re.IGNORECASE | re.MULTILINE):
                sql = "SELECT * FROM ( " + sql + " ) as z99 "
            else:
                sql = "SELECT * FROM " + sql + " "
        sql = sql.replace("%", '%%')
    
        where, vals = _make_where_conditions(flt)
    
        if where is not None:
            sql += " WHERE " + where
    
        if group_by is not None and len(group_by):
            sql += " GROUP BY " + ",".join(group_by)
    
        if order is not None and len(order):
            order_fields = []
            for field, direction in order.items():
                order_fields.append(field + " " + direction)
            sql += " ORDER BY " + ",".join(order_fields)
        if limit is not None:
            sql += " LIMIT %s"
            vals.append(limit)
        if offset is not None:
            sql += " OFFSET %s"
            vals.append(offset)
        if lock is not None:
            sql += " FOR " + lock
    
        return sql, vals

    Конструктор SQL запроосов, все очень секурно!

    agent-0007, 21 Мая 2018

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