why cannot assign to function call
steve at holdenweb.com
Wed Jan 7 22:35:53 CET 2009
Dan Esch wrote:
> Wait a sec...
> I think I get this...
> 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. We may or may not have realized that string in a memory address to
> which variable names can be bound, but should we do so, there is only
> one "parrot"
> Python, is in fact, a Platonic programming language. Weird. If I've
> got this right, worth chewing on....
'Fraid not. Certain immutables are cached by the interpreter, but most
>>> s1 = "a" + "b" + "c"
>>> n = 12345
>>> s2 = "ab" + chr(99)
>>> m = 2469 * 5
>>> s1 == s2
>>> s1 is s2
>>> n == m
>>> n is m
>>> id(s1), id(s2), id(n), id(m)
(2146661888, 2146661792, 14453620, 14453584)
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list