Dan Esch wrote:

In essence, the implication of immutability for Python is that there is only one "parrot", one "spam,"in fact one anything. (This seems like it must hold for data primitives - does it hold for complex objects as well? It seems it must...) In addition there is only one 1, and one 2 etc.

That's not necessarily true.  If you have

  a = "par" + "rot"
  b = "parrot"

then, most likely (though it depends on how clever the compiler optimizations are), there are two different string objects containing the data "parrot". In this case, "a == b" is true because string equality testing compares the data, but "a is b" is false because a and b refer to different objects.

And by the way, don't let the people claiming that Python's assignment model is bizarre confuse you. Assignment and parameter-passing in Python is exactly the same as in any other modern OOP language; it just so happens that in Python, all variables are references, while in most other languages, some variables are references and others are primitive types. But it should be obvious (though apparently isn't, to some) that this restricted, uniform data model does not fundamentally change anything; it just makes Python a little more restricted and uniform. For details, see: <http://www.strout.net/info/coding/valref/>

Best,
- Joe


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to