Common mistakes we make in Python and why we should avoid that part 2

  • First, its memory reference — Memory id can be found using the id function.
  • Second, its value
>>> a = [1, 2, 3] 
>>> b = [1, 2, 3]
>>> a == b True
>>> a is b False
>>> id(a) 140281424436160
>>> id(b) 140281424966208
>>> a = [1,2,3]
>>> b = a
>>> a == b True
>>> a is b True
>>> id(a) 140281424966208
>>> id(b) 140281424966208
>>>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store