Is behavior of += intentional for int?

zaur szport at gmail.com
Sun Aug 30 12:37:49 EDT 2009


On 30 авг, 15:49, Carl Banks <pavlovevide... at gmail.com> 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.

So this isn't the case.



More information about the Python-list mailing list