Python 2.0b1 is released!
Thomas Wouters
thomas at xs4all.net
Wed Sep 20 09:54:48 EDT 2000
On Fri, Sep 08, 2000 at 03:58:29PM +0200, Richard van de Stadt wrote:
> Talking about adding 1 to x:
> Are x++, ++x now also allowed?
> (did someone say c++?)
They're not valid syntax, if that's what you mean. They are allowed, though,
in code such as this:
print x++ 1
It just doesn't do what you intend it to do ;-)
The auto-increment/decrement operators were not added because they do not
nearly make as much sense as the augmented assignment operators: like their
names suggest, they are intended to 'increment' a value, and practically
never used for something other than a number (don't get me started on Perl's
"string"++, please ;P) or a pointer (which is also a number.) Python doesn't
have pointers, doesn't need pointers, numbers are immutable, and the need to
increment a number is much less frequent, in Python. You usually do
for i in range(100):
...code...
rather than
int i;
for (i=0; i<100; i++)
...code...
or
y = "string"
x = y
rather than
char * y = "string"
char x[100];
while (y != '\0')
x++ = *y++;
--
Thomas Wouters <thomas at xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
More information about the Python-list
mailing list