Is behavior of += intentional for int?

Derek Martin code at pizzashack.org
Sun Aug 30 19:04:45 CEST 2009


On Sun, Aug 30, 2009 at 03:42:06AM -0700, Paul McGuire wrote:
> Python binds values to names. Always. 

No, actually, it doesn't.  It binds *objects* to names.  This
distinction is subtle, but important, as it is the crux of why this is
confusing to people.  If Python is to say that objects have values,
then the object can not *be* the value that it has, because that is a
paradoxical self-reference.  It's an object, not a value.

> Is it any odder that 3 is an object than that the string literal
> "Hello, World!" is an object?  

Yes.  Because 3 is a fundamental bit of data that the hardware knows
how to deal with, requiring no higher level abstractions for the
programmer to use it (though certainly, a programming language can
provide them, if it is convenient).  "Hello, World!" is not.  They are
fundamentally different in that way.

> For a Python long-timer like Mr. D'Aprano, I don't think he even
> consciously thinks about this kind of thing any more; his intuition
> has aligned with the Python stars, so he extrapolates from the OP's
> suggestion to the resulting aberrant behavior, as he posted it.

I'm sure that's the case.  But it's been explained to him before, and
yet he still can't seem to comprehend that not everyone immediately
gets this behavior, and that this is not without good reason.

So, since it *has* been explained to him before, it's somewhat
astonishing that he would reply to zaur's post, saying that the
behavior zaur described would necessarily lead to the insane behavior
that Steven described.  When he makes such statements, it's tantamount
to calling the OP an idiot.  I find that offensive, especially
considering that Steven's post displayed an overwhelming lack of
understanding of what the OP was trying to say.

> You can dispute and rail at this core language concept if you like,
> but I think the more entrenched you become in the position that "'3 is
> an object' is bizarre", the less enjoyable your Python work will be.

While I did genuinely find the behavior bizarre when I encountered it,
and honestly still do, I learned it quickly and moved past it.  I'm
not suggesting that it be changed, and I don't feel particularly
strongly that it even should change.  It's not so much the language
I'm railing against, but the humans...

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090830/42b17fcc/attachment.pgp>


More information about the Python-list mailing list