Is behavior of += intentional for int?

Rhodri James rhodri at
Sun Aug 30 18:57:23 CEST 2009

On Sun, 30 Aug 2009 17:37:49 +0100, zaur <szport at> wrote:

> On 30 авг, 15:49, Carl Banks <pavlovevide... at> wrote:
>> I think they (Derek and zaur) expect integer objects to be mutable.
>> It's pretty common for people coming from "name is a location in
>> memory" languages to have this conception of integers as an
>> intermediate stage of learning Python's object system.  Even once
>> they've understood "everything is an object" and "names are references
>> to objects" they won't have learned all the nuances of the system, and
>> might still (not unreasonably) think integer objects could be mutable.
>> However, it'd be nice if all these people didn't post here whining
>> about how surprising and unintuitive it is and instead just said, "ah,
>> integers are immutable, got it", quietly to themselves.
>> Carl Banks
> Very expressive.
> I use python many years. And many years I just took python int as they
> are.
> I am also not think about names as reference to objects and so on.

Then you are doomed to surprises such as this.

Rhodri James *-* Wildebeest Herder to the Masses

More information about the Python-list mailing list