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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    a1=[gg for gg in range( 1,  9+ 1   , 1) ]
    b1='';b2=""
    for a in a1:
        for A1 in a1:
            b1=b1 + str(a)+'*'  +  str(A1)+ '='  +'%s' %str(int( a )* int(A1 ) )+"  "
        b2+=b1+ '\n'
        del b1; b1=''
    print(f'{b2}' )

    ТаблицаУмножения

    mosni, 30 Мая 2020

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

    +2

    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
    def get_build_version():
        """Return the version of MSVC that was used to build Python.
    
        For Python 2.3 and up, the version number is included in
        sys.version.  For earlier versions, assume the compiler is MSVC 6.
        """
        prefix = "MSC v."
        i = sys.version.find(prefix)
        if i == -1:
            return 6
        i = i + len(prefix)
        s, rest = sys.version[i:].split(" ", 1)
        majorVersion = int(s[:-2]) - 6
        if majorVersion >= 13:
            # v13 was skipped and should be v14
            majorVersion += 1
        minorVersion = int(s[2:3]) / 10.0
        # I don't think paths are affected by minor version in version 6
        if majorVersion == 6:
            minorVersion = 0
        if majorVersion >= 6:
            return majorVersion + minorVersion
        # else we don't know what version of the compiler this is
        return None

    Определение версии конпелятора, которой был собран «CPython».

    TEH3OPHblu_nemyx, 30 Мая 2020

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

    +1

    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
    from tkinter import *
    from random import randint
    
    f = randint(2, 10)
    s = randint(2, 10)
    r = f * s
    def main_f():
        global f
        global s
        global r
        if r == int(inp.get()):
            ls.configure(text='да! Вы правы')
            f = randint(2, 10)
            s = randint(2, 10)
            r = f * s
            l.configure(text=f'сколько будет {f} * {s}?')
        else:
            ls.configure(text='нет, вы не правы')
            
            l.configure(text=f'сколько будет {f} * {s}?')
        
    
    win = Tk()
    win.title('math')
    
    l = Label(win, text=f'сколько будет {f} * {s}?')
    l.grid(column=0 , row=0)
    
    ls = Label(win, text=' ')
    ls.grid(column=0, row=1)
    
    inp = Entry(win, width=10)
    inp.grid(column=1, row=0)
    
    but = Button(win, text='проверить', command=main_f, fg='red')
    but.grid(column=2, row=0)
    
    win.mainloop()

    третьиклассник решил выучить таблицу умножения

    BananiumPower, 19 Мая 2020

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    post_content = post_node.xpath('div[@class="entry-content"]')[0]
    post_code_nodes = post_content.xpath('.//code')
    if len(post_code_nodes) > 0:
        post.code = post_code_nodes[0].text
    else:
        post.code = inner_html_ru(post_content)

    Багор.

    gost, 19 Мая 2020

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    post_content = post_node.xpath('div[@class="entry-content"]')[0]
    post_code_nodes = post_content.xpath('.//code')
    if len(post_code_nodes) > 0:
        post.code = post_code_nodes[0].text
    else:
        post.code = inner_html_ru(post_content)

    Багор.

    gost, 19 Мая 2020

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

    +1

    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
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    from vk_bot.vk_config import GROUP_ID, TOKEN
    import vk_api
    from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
    import random
    from vk_bot.db_session import *
    from vk_bot.__all_models import BugReport, Comment
    import datetime
    from vk_bot.vacancies import get_vacancies, ServerError
    
    
    def main():
        global_init("feedback/feedback.sqlite")
        vk_session = vk_api.VkApi(
            token=TOKEN)
        vk = vk_session.get_api()
    
        longpoll = VkBotLongPoll(vk_session, GROUP_ID)
        bot_state = {}
    
        def send_msg(msg):
            vk.messages.send(user_id=event.obj.message['from_id'],
                             message=msg,
                             random_id=random.randint(0, 2 ** 64))
    
        for event in longpoll.listen():
            if event.type == VkBotEventType.MESSAGE_NEW:
                if event.obj.message['from_id'] in bot_state and bot_state[event.obj.message['from_id']]:
                    state = bot_state[event.obj.message['from_id']]
                    if state == 1:
                        send_msg('Спасибо, ваше мнение для нас очень важно.')
                        Comment().new(event.obj.message['from_id'], datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                                      event.obj.message['text'])
                        bot_state[event.obj.message['from_id']] = 0
                    elif state == 2:
                        BugReport().new(event.obj.message['from_id'], datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                                        event.obj.message['text'])
                        send_msg('Спасибо за ваш отзыв, мы постараемся исправить проблему в ближайшем будущем.')
                        bot_state[event.obj.message['from_id']] = 0
                    elif state == 4:
                        parameters = [r.strip() for r in event.obj.message['text'].split(',')]
                        try:
                            vacancies = get_vacancies(parameters[0], parameters[1])
                        except ServerError:
                            send_msg('Не удалось получить ответ от сервера, попробуйте позже')
                            bot_state[event.obj.message['from_id']] = 0
                        except Exception:
                            send_msg('Данные введены некорректно, попробуйте заново.')
                            send_msg('Формат: <должность>, <мин. зарплата>')
                        else:
                            if len(vacancies) == 0:
                                send_msg('По данным критериям ничего не найдено')
                            else:
                                vacancy_list = [f"{i}) {v['title']}, {v['salary']}" for i, v in enumerate(vacancies)]
                                send_msg('\n'.join(vacancy_list))
    
                    if bot_state[event.obj.message['from_id']] == 0:
                        send_msg('1 - написать отзыв или предложение\n 2 - сообщить о неправильной работе сайта\n 3 - документация к api\n 4 - посмотреть список доступных вакансий\n иначе напишите сообщение и модератор вскоре на него ответит')
    
                elif event.obj.message['from_id'] not in bot_state:
                    send_msg('1 - написать отзыв или предложение\n 2 - сообщить о неправильной работе сайта\n 3 - документация к api\n 4 - посмотреть список доступных вакансий\n иначе напишите сообщение и модератор вскоре на него ответит')
                    bot_state[event.obj.message['from_id']] = 0
                else:
                    key = event.obj.message['text'][0]
                    if key == '1':
                        send_msg('Пожалуйста, поделитесь вашим мнением по поводу сайта.')
                        bot_state[event.obj.message['from_id']] = 1
                    elif key == '2':
                        send_msg('Пожалуйста, максимально подробно опишите вашу проблему.')
                        bot_state[event.obj.message['from_id']] = 2
                    elif key == '3':
                        send_msg('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
                    elif key == '4':
                        send_msg('Введите название должности и минимальную желаемую зарплату по образцу:<должность>, <мин. зарплата>')
                        bot_state[event.obj.message['from_id']] = 4
                    else:
                        send_msg('Модератор вам скоро ответит, пожалуйста подождите.')
    
    
    if __name__ == '__main__':
        main()

    Код бота поддержки.
    Один из товарищей по проекту ничего в нем не делал,
    а потом чтобы его не выгоняли попросил дать ему хотя бы бота.
    Вот результат.
    Модели и вспомогательные файлы оставлять думаю не имеет смысла, все и так очевидно

    AlexandrovRoman, 13 Мая 2020

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    def f(m, n):
         if m == 0:
              return n + 1
         elif n == 0:
              return f(m - 1, 1)
         else:
              return f(m - 1, f(m, n - 1))

    vvudu, 08 Мая 2020

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

    +1

    1. 1
    https://github.com/oskusalerma/trelby/issues/85

    Сорян за пост-ссылку, но я тут валяюсь под столом просто.

    Есть тулза для написания сценариев (для чего только нет тулзы, правда?). Она опенсурсная и при этом выглядит не как говно. Но, когда начинаешь её щупать, ВНЕЗАПНО оказывается, что буквы кириллицы в ней тупо не набираются. Лезешь в FAQ, там лежит ссылка на issue из поста. А уже там просто сказка!

    Короч, автор примерно в 2007 году сходил почитал спеку пдф, обнаружил, что "PDF spec is oriented towards Latin-1" и решил, что это даёт ему моральное право забить болт на Unicode, а заодно utf-8 и унтерменш, которые не осилили самый тривиальный сабсет латиницы.

    В 2012-ом после, судя по всему, многочисленных недоумённых вопросов автор снова появился на горизонте с тикетом на гитхабе и объяснениями в духе "Unicode нет и не будет, потому что не для тебя моя черешня цвела". Цитата для понимания майндсета чувака: "That's how it was 5 years ago anyway when I last looked at it; maybe the spec has improved since then?"

    В общем, выглядело так, будто дядя устал и решил, что пора бы всю эту хуйню переложить на чужие хрупкие плечи, у нас тут опенсурс тем более и все дела.

    Но, когда в 2015-ом году появился некий анон с предложением все починить и даже какими-то наработками, автор ему сказал, что иди сука гоняй тесты (видимо, руками, потому что CI настроить он тоже не смог) на всех платформах, а то, вишь, "the old "I'll do the fun bits and let others do the boring bits" strategy. Good luck with that."

    Короч чуваки ещё немного поспорили с этим аутистом, после чего съебались в туман, а тулза так кириллицу и не поддерживает.

    Смешно и грустно.

    Desktop, 05 Мая 2020

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

    −1

    1. 1
    IT Оффтоп #43

    #9: https://govnokod.ru/24867 https://govnokod.xyz/_24867
    #10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
    #11: (vanished) https://govnokod.xyz/_25436
    #12: (vanished) https://govnokod.xyz/_25471
    #13: (vanished) https://govnokod.xyz/_25590
    #14: https://govnokod.ru/25684 https://govnokod.xyz/_25684
    #15: https://govnokod.ru/25694 https://govnokod.xyz/_25694
    #16: https://govnokod.ru/25725 https://govnokod.xyz/_25725
    #17: https://govnokod.ru/25731 https://govnokod.xyz/_25731
    #18: https://govnokod.ru/25762 https://govnokod.xyz/_25762
    #19: https://govnokod.ru/25767 https://govnokod.xyz/_25767
    #20: https://govnokod.ru/25776 https://govnokod.xyz/_25776
    #21: https://govnokod.ru/25798 https://govnokod.xyz/_25798
    #22: https://govnokod.ru/25811 https://govnokod.xyz/_25811
    #23: https://govnokod.ru/25863 https://govnokod.xyz/_25863
    #24: https://govnokod.ru/25941 https://govnokod.xyz/_25941
    #25: https://govnokod.ru/26026 https://govnokod.xyz/_26026
    #26: https://govnokod.ru/26050 https://govnokod.xyz/_26050
    #27: https://govnokod.ru/26340 https://govnokod.xyz/_26340
    #28: https://govnokod.ru/26372 https://govnokod.xyz/_26372
    #29: https://govnokod.ru/26385 https://govnokod.xyz/_26385
    #30: https://govnokod.ru/26413 https://govnokod.xyz/_26413
    #31: https://govnokod.ru/26423 https://govnokod.xyz/_26423
    #32: https://govnokod.ru/26440 https://govnokod.xyz/_26440
    #33: https://govnokod.ru/26449 https://govnokod.xyz/_26449
    #34: https://govnokod.ru/26456 https://govnokod.xyz/_26456
    #35: https://govnokod.ru/26463 https://govnokod.xyz/_26463
    #36: https://govnokod.ru/26508 https://govnokod.xyz/_26508
    #37: https://govnokod.ru/26524 https://govnokod.xyz/_26524
    #38: https://govnokod.ru/26539 https://govnokod.xyz/_26539
    #39: https://govnokod.ru/26556 https://govnokod.xyz/_26556
    #40: https://govnokod.ru/26568 https://govnokod.xyz/_26568
    #41: https://govnokod.ru/26589 https://govnokod.xyz/_26589
    #42: https://govnokod.ru/26600 https://govnokod.xyz/_26600

    gost, 27 Апреля 2020

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

    0

    1. 1
    2. 2
    3. 3
    a=1
    b=2
    a+b

    Я сделаль

    Vanilla, 07 Апреля 2020

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