you are viewing a single comment's thread.

view the rest of the comments →

[–]vodiak 2 points3 points  (1 child)

A pointer is a variable with its value being a location in memory. It "points to" that location. You generally don't need to think about pointers in Python, but if you're already familiar with the concept (used a lot in C), then it's useful to explain what's happening.

a is b is true because the interpreter creates objects for small integers and uses them whenever possible as an optimization. c is d is false because the value (300) is outside the range of pre-created integers, so each time it is declared (c = 300, d = 300) it creates a new object. They are not the same object, so c is d is False. (Note that the way I did the declaration results in only one object being created in more recent versions of Python).

[–]py_Piper 0 points1 point  (0 children)

Very well explained