Dale Strickland-Clark dale at
Tue Feb 25 19:46:31 CET 2003

Alex Martelli <aleax at> wrote:

>In Python, all binding and rebinding of names is in statements, never in 
>expressions; and numbers are immutable -- so if x refers for example to
>the number 3, there is no way to make x refer to the number 4 except by
>rebinding name x to a different object (you cannot ALTER a number).
>I had not imagined the original poster was asking for Python to be
>entirely and drastically revolutionized -- making numbers mutable, or
>letting name binding or rebinding happen in expressions and not just
>in statements -- in order to let him save A FEW characters' worth of
>typing; I had rather made more charitable assumptions about what he
>was asking about/for.
>If the question being asked is "why are numbers immutable" or "why
>does Python distinguish between expressions and statements and never
>lets operators bind or rebind the names they're applied to", then
>the only sensible answer is "because it's Python -- if you want C,
>you know where to find it".
>If the question is "why doesn't Python make an exception to its
>otherwise simple and universal rules in order to treat an extremely
>specific case 'ad hoc' in a way that would be convenient to me",
>then my suggestion would be to switch to Perl: in that language you
>will find an endless, dazzling variety of such "convenient" design
>choices -- bon appetit!
>Since I keep assuming human being are fundamentally good, even though
>sometimes misguided, I still prefer to keep also assuming that the
>poster, as indicated by using the non-C terminology "autoincrement"
>rather than the C terminology "preincrement" or "postincrement", was
>NOT wondering about inflicting such horrors upon Python, but simply
>about a "++" synonym for the construct "+=1" -- a statement rebinding
>a reference, but NOT returning a result.
  >phew!< You're hard going sometimes. :)
Dale Strickland-Clark
Riverhall Systems Ltd

More information about the Python-list mailing list