integers ( ++ operator ? )
Nick Perkins
nperkins7 at home.com
Wed Jun 6 00:04:39 EDT 2001
More information about the Python-list mailing list
Wed Jun 6 00:04:39 EDT 2001
- Previous message (by thread): integers
- Next message (by thread): integers ( ++ operator ? )
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Alan Daniels" <daniels at mindspring.com> wrote in message > I believe the new "x += 1" syntax is just synactic sugar which serves > as shorthand for "x = x + 1", although I'd have to delve through the > interpreter source code to be 100% sure. ..no need to look at the interpreter source: >>> x=10 >>> id(x) 3161552 >>> x+=1 >>> id(x) 3161960 x does indeed refer to a different object. In other languages, this effect could be written something like: x = new Integer( x.intValue() + 1 ) ..the object that x used to refer to, is simply garbage-collected. (unless other names also refer to it). I don't think I need x++ when x+=1 is only one character more. Furthermore, if we had x++ people would be tempted to use it inside an expression, which I think would have to be illegal. ( I defer to the experts on that point )
- Previous message (by thread): integers
- Next message (by thread): integers ( ++ operator ? )
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list