Simon Brunning wrote:
On 13 Jan 2005 07:18:26 EST, Tim Daneliuk <[EMAIL PROTECTED]> wrote:
But you are being mislead by the fact that integers are immutable.
'spam.eggs = 2' is *creating* an instance member - there wasn't one
before. Have a look at what happens with a mutable object:
Simon, it's really not about mutability at all. You've changed
the example, which was binding a name (specifically setting an
attribute), to one in which you are simply calling a method on
the object. If you change your example to bind the name the
same way, even with a mutable, it will work the same way as Tim's
original did with integers:
class Spam(object):
... eggs = [3]
...
spam = Spam()
spam2 = Spam()
spam.eggs = [7]
>>> spam2.eggs
[3]
-Peter
--
http://mail.python.org/mailman/listinfo/python-list