Skip to content

Instantly share code, notes, and snippets.

@marceloandriolli
Created February 15, 2018 17:38
Show Gist options
  • Save marceloandriolli/583645d94a7a521f78f79ab44c8fb23f to your computer and use it in GitHub Desktop.
Save marceloandriolli/583645d94a7a521f78f79ab44c8fb23f to your computer and use it in GitHub Desktop.
>>> fruit = 'apple'
>>> fruit is 'apple'
True
>>> fruit == 'apple'
True
>> id(fruit), id('apple')
(140031285906720, 140031285906720)
>>> id(fruit), id('orange')
(140031285906720, 140031285906912)
# why? How python infers that id of fruit is the same of 'apple', if a object has same value, would be same id?
@luzfcb
Copy link

luzfcb commented Feb 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment