Robert Dailey wrote: > So immutable objects cannot be modified directly? I guess this means > integers are immutable and the act of assigning to one is a completely > new definition?
Correct. A new value is bound to the name or item on the left-hand side - remember, all variables are pointers to values, there's no way to replace the value of a variable because of the automatic dereferencing. And yes, immutable objects can't be modified. At all, period. Hence the name. > So if I were to create a class called Integer and give > it a .set() method, this would allow me to create mutable integers, and > thus passing in an object of type class Integer would allow me to modify > the value from inside the function? > Well, the .set() method wouldn't be called automatically on an assignment statement but yes, if you passed an Integer object into your function and called its .set() method from inside then it should work. As long as you get your mutable integer implementation correct, of course ;-). I'd suggest delegating everything except the .set() method to the underlying integer value. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- http://mail.python.org/mailman/listinfo/python-list