[Python] Why does Python Tutor draw strings and integers in a list without a pointer although...

Discussão em 'Python' iniciado por Stack, Janeiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I read that "everything is a reference in python".

    Though, when I run in Python Tutor the following code:

    lst = [1,[1]]


    lst[1] is drawn as an arrow pointing to a list while lst[0] is just the number 1.

    I also understand that what makes the difference is that lst[0] is immutable and lst[1] is mutable. I still don't get how to explain the drawing in Python Tutor, or any other explanation.

    The drawing in Python Tutor looks as if the number itself is saved in lst[0] and not a reference, but I guess this is wrong because "everything in python is a reference".

    How can we explain the drawing otherwise? Is the drawing in Python Tutor misleading and there is actually an address stored in lst[0]?

    Continue reading...

Compartilhe esta Página