0

We see a lot of operations on lists using its index like L[index] and we get the value associated with that index in a particular list.

I have a doubt on what exactly is python doing when we say "get me an element at this particular index(L[index])".

Is L[index] like a pointer which points to a particular value in the list and is it the reason why the value is changed through the assignment L[index]=value in the same address unlike other variables?

Any help on this would be appreciated.

Bhanu sri
  • 31
  • 3

1 Answers1

0

Is L[index] like a pointer which points to a particular value in the list ...

No. It is an indicator to the compiler that the __getitem__(), __setitem__(), or __delitem__() method (or their C-level equivalents) of the object should be called depending on which operation is required.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358