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

Поділитися
Вставка
  • Опубліковано 6 лис 2024

КОМЕНТАРІ • 15

  • @Astolfinho463
    @Astolfinho463 2 місяці тому +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.. 2 місяці тому

      haiiiiii astolfo :3

    • @jinyiliu2102
      @jinyiliu2102 2 місяці тому

      I totally agree 👍🏻

  • @EdgarDarmstadtio
    @EdgarDarmstadtio 2 місяці тому +20

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

  • @zeerakkhan274
    @zeerakkhan274 2 місяці тому

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

  • @roblesman17
    @roblesman17 2 місяці тому +2

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

    • @Indently
      @Indently  2 місяці тому +3

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

  • @lostyguy7602
    @lostyguy7602 2 місяці тому

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

  • @BohonChina
    @BohonChina 2 місяці тому +1

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

    • @dflolcool4180
      @dflolcool4180 2 місяці тому

      Yea more people need to use it

  • @cegexen8191
    @cegexen8191 2 місяці тому +1

    Are all iterables subscriptable ?

    • @lucyper8921
      @lucyper8921 2 місяці тому +1

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

    • @EdgarDarmstadtio
      @EdgarDarmstadtio 2 місяці тому +2

      generators aren't

  • @rishiraj2548
    @rishiraj2548 2 місяці тому +1

    Good day greetings

  • @jimmlmao
    @jimmlmao 2 місяці тому +1

    it does not support [doing this]