3 ms·
Everything in Python is an object. In Python, containers are objects that reference other objects. https://docs.python.org/3/reference/datamodel.html https://d
by brudgers 7y ago
Everything in Python is an object. In Python, containers are objects that reference other objects.
https://docs.python.org/3/reference/datamodel.html https://docs.python.org/3/reference/datamodel.html
https://docs.python.org/2.0/ref/objects.html https://docs.python.org/2.0/ref/objects.html
- dorfsmay 7y agoHow are name bindings different than references? >>> a=[2, 3, 1] >>> b=a >>> id(a) 139731931982216 >>> id(b) 139731931982216 >>> b [2, 3, 1] >>> b.sort() >>> del(b) >>> a [1, 2, 3] >>>
- fulafel 7y agoDepends what you mean by reference. In Python they are indeed synonymous. C++ references are different in that the binding / object identity can be changed through the reference, eg when you pass a reference to a function.
- brudgers 7y agoIn Python, lists are container objects. Container objects reference other objects. In the first line object a references objects 2, 3 ,and 1 (and any other objects in a's object heritage). 2, 3 and 1 have id's. That's what "everything is an object" fleshes out to in Python. But they don't reference other objects because they are literals. The value of 2 is also its name.