Variable Scopes in Python global vs local - Python Short Series Ep.117

Поделиться
HTML-код
  • Опубликовано: 20 окт 2024

Комментарии • 6

  • @hvl8a6nguyenthanhtai72
    @hvl8a6nguyenthanhtai72 3 месяца назад +2

    when assign x = x + 1
    python thinks x is declared as a local var , as a result it trys to to find the value of x inside the function , if cant found , we'll receive an error which says "UnboundLocalError: local variable 'x' referenced before assignment"

  • @gamingland2074
    @gamingland2074 Год назад +2

    u need to declare global before the variable but never used it in my life bcs there's no reason

    • @youssefbenhachem993
      @youssefbenhachem993 10 месяцев назад

      Could be useful for debugging if u dont have access to debugging libraries which could be the case in your professional work

    • @code2compass
      @code2compass 7 месяцев назад

      Worked with it a lot back in the days when I was designing a GPS signal generator @@youssefbenhachem993

  • @phinehasuchegbu8068
    @phinehasuchegbu8068 Год назад +3

    Part 2?

    • @codetodesign
      @codetodesign  Год назад +1

      The second part will be uploaded today. Once it's uploaded, I'll share the link.