What Does "Object is Not Subscriptable" Really Mean In Python?

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

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

  • @Astolfinho2469
    @Astolfinho2469 5 месяцев назад +1

    Thank you so much for this! I'm trying to learn python and you're the best kind of teacher we can have on youtube.

    • @proton..
      @proton.. 5 месяцев назад

      haiiiiii astolfo :3

    • @jinyiliu2102
      @jinyiliu2102 5 месяцев назад

      I totally agree 👍🏻

  • @EdgarDarmstadtio
    @EdgarDarmstadtio 5 месяцев назад +22

    you really have an obsession with type hints don't you

  • @BohonChina
    @BohonChina 5 месяцев назад +2

    The pythonic way to handle the 1st example situation is to use defaultdict, Python will generate default values for missing keys

    • @dflolcool4180
      @dflolcool4180 5 месяцев назад

      Yea more people need to use it

  • @roblesman17
    @roblesman17 5 месяцев назад +2

    what would you return on the setitem and delitem functions to set it up correctly?

    • @Indently
      @Indently  5 месяцев назад +3

      I would probably return -> None since they are just performing operations with no output.

  • @lostyguy7602
    @lostyguy7602 5 месяцев назад

    Could you explain how to use 'self'? like in def xyz(self): ?

  • @rishiraj2548
    @rishiraj2548 5 месяцев назад +1

    Good day greetings

  • @zeerakkhan274
    @zeerakkhan274 5 месяцев назад

    Great Explanation of the error and how to avoid it. I was just thinking about the Use Case of creating custom subcriptable objects? 🤔

  • @jimmlmao
    @jimmlmao 5 месяцев назад +1

    it does not support [doing this]

  • @cegexen8191
    @cegexen8191 5 месяцев назад +1

    Are all iterables subscriptable ?

    • @lucyper8921
      @lucyper8921 5 месяцев назад +1

      depends on the type, example is enumerate(), you can iterate but isn't subscriptable

    • @EdgarDarmstadtio
      @EdgarDarmstadtio 5 месяцев назад +2

      generators aren't