Easy way to keep counting up infinitely
up vote
5
down vote
favorite
What's a good way to keep counting up infinitely? I'm trying to write a condition that will keep going until there's no value in a database, so it's going to iterate from 0, up to theoretically infinity (inside a try block, of course).
How would I count upwards infinitely? Or should I use something else?
I am looking for something similar to i++ in other languages, where it keeps iterating until failure.
python
add a comment |
up vote
5
down vote
favorite
What's a good way to keep counting up infinitely? I'm trying to write a condition that will keep going until there's no value in a database, so it's going to iterate from 0, up to theoretically infinity (inside a try block, of course).
How would I count upwards infinitely? Or should I use something else?
I am looking for something similar to i++ in other languages, where it keeps iterating until failure.
python
Also, why doesn't Python have i++? Literally every other language I've worked in does, and it seems like a glaring hole.
– Andrew Alexander
Jul 11 '12 at 2:49
6
1)i++
is syntactic sugar and I doubt that you can call it's exclusion a "glaring hole". 2) Python usesi += 1
because it is more explicit about the increment. 3) Guido decided it was so.
– Joel Cornett
Jul 11 '12 at 2:51
2
i+=1 is only one more character
– user485498
Jul 11 '12 at 2:51
4
@AndrewAlexander "There should be one-- and preferably only one --obvious way to do it."
– jamylak
Jul 11 '12 at 2:53
add a comment |
up vote
5
down vote
favorite
up vote
5
down vote
favorite
What's a good way to keep counting up infinitely? I'm trying to write a condition that will keep going until there's no value in a database, so it's going to iterate from 0, up to theoretically infinity (inside a try block, of course).
How would I count upwards infinitely? Or should I use something else?
I am looking for something similar to i++ in other languages, where it keeps iterating until failure.
python
What's a good way to keep counting up infinitely? I'm trying to write a condition that will keep going until there's no value in a database, so it's going to iterate from 0, up to theoretically infinity (inside a try block, of course).
How would I count upwards infinitely? Or should I use something else?
I am looking for something similar to i++ in other languages, where it keeps iterating until failure.
python
python
asked Jul 11 '12 at 2:43
Andrew Alexander
2,9852075135
2,9852075135
Also, why doesn't Python have i++? Literally every other language I've worked in does, and it seems like a glaring hole.
– Andrew Alexander
Jul 11 '12 at 2:49
6
1)i++
is syntactic sugar and I doubt that you can call it's exclusion a "glaring hole". 2) Python usesi += 1
because it is more explicit about the increment. 3) Guido decided it was so.
– Joel Cornett
Jul 11 '12 at 2:51
2
i+=1 is only one more character
– user485498
Jul 11 '12 at 2:51
4
@AndrewAlexander "There should be one-- and preferably only one --obvious way to do it."
– jamylak
Jul 11 '12 at 2:53
add a comment |
Also, why doesn't Python have i++? Literally every other language I've worked in does, and it seems like a glaring hole.
– Andrew Alexander
Jul 11 '12 at 2:49
6
1)i++
is syntactic sugar and I doubt that you can call it's exclusion a "glaring hole". 2) Python usesi += 1
because it is more explicit about the increment. 3) Guido decided it was so.
– Joel Cornett
Jul 11 '12 at 2:51
2
i+=1 is only one more character
– user485498
Jul 11 '12 at 2:51
4
@AndrewAlexander "There should be one-- and preferably only one --obvious way to do it."
– jamylak
Jul 11 '12 at 2:53
Also, why doesn't Python have i++? Literally every other language I've worked in does, and it seems like a glaring hole.
– Andrew Alexander
Jul 11 '12 at 2:49
Also, why doesn't Python have i++? Literally every other language I've worked in does, and it seems like a glaring hole.
– Andrew Alexander
Jul 11 '12 at 2:49
6
6
1)
i++
is syntactic sugar and I doubt that you can call it's exclusion a "glaring hole". 2) Python uses i += 1
because it is more explicit about the increment. 3) Guido decided it was so.– Joel Cornett
Jul 11 '12 at 2:51
1)
i++
is syntactic sugar and I doubt that you can call it's exclusion a "glaring hole". 2) Python uses i += 1
because it is more explicit about the increment. 3) Guido decided it was so.– Joel Cornett
Jul 11 '12 at 2:51
2
2
i+=1 is only one more character
– user485498
Jul 11 '12 at 2:51
i+=1 is only one more character
– user485498
Jul 11 '12 at 2:51
4
4
@AndrewAlexander "There should be one-- and preferably only one --obvious way to do it."
– jamylak
Jul 11 '12 at 2:53
@AndrewAlexander "There should be one-- and preferably only one --obvious way to do it."
– jamylak
Jul 11 '12 at 2:53
add a comment |
4 Answers
4
active
oldest
votes
up vote
20
down vote
accepted
Take a look at itertools.count().
From the docs:
count(start=0, step=1)
--> count object
Make an iterator that returns evenly spaced values starting with
n
.
Equivalent to:
def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 ...
# count(2.5, 0.5) -> 2.5 3.0 3.5 ...
n = start
while True:
yield n
n += step
So for example:
import itertools
for i in itertools.count(13):
print(i)
would generate an infinite sequence starting with 13, in steps of +1. And, I hadn't tried this before, but you can count down too of course:
for i in itertools.count(100, -5):
print(i)
starts at 100, and keeps subtracting 5 for each new value ....
1
Beat me to it...
– jamylak
Jul 11 '12 at 2:45
1
@jamylak got lucky:)
– Levon
Jul 11 '12 at 2:45
I just couldn't stand the SO auto code formatter incorrect colors :)
– jamylak
Jul 11 '12 at 3:38
add a comment |
up vote
0
down vote
This is a bit smaller code than what the other user provided!
x = 1
while True:
x = x+1
print x
I likecount
but this is also valid and can come in handy if you need multiple counters. Would update tox += 1
– CasualDemon
Oct 5 '17 at 21:04
add a comment |
up vote
0
down vote
A little shorter, using an iterator and no library:
x = 0
for x in iter(lambda: x+1, -1):
print(x)
But it requires a variable in the current scope.
add a comment |
up vote
-1
down vote
xrange
will give you an iterable object that won't use memory as you iterate, a for
loop is cleaner than a while
loop + counter if you ask me.
import sys
for i in xrange(0,sys.maxint):
print i
Not really infinite because it stops atsys.maxint
, after which the domain of thelong
integers start automagically.
– Eric
Nov 10 at 23:37
Not infinite, but "similar to i++ in other languages" though. And of course x=0, 1, 2... will overflow at the same point that this fails anyway, so the solution you have posed has the same limitation effectively. Truly infinite would have to use a big decimal style library that can store arbitrarily large values.
– David Parks
Nov 12 at 18:50
No solution I see here proposes anything that is capable of going pastsys.maxint
, so I contend that this is still the cleanest and clearest way to code this, under the assumption that one doesn't need more than9,223,372,036,854,775,807
loop iterations.
– David Parks
Nov 12 at 19:00
1
You're right it's a generator that is good enough in almost all practical cases, it's good way to cope with the practical problem. However it's limited to 2,147,483,647 on 32-bit machines, 2 giga is a reasonably achievable number in many applications. And it doesn't answer the question which is to make an infinite generator. Appart from that, you might not know that in python integers higher thansys.maxint
are supported natively and transparently via thelong
type, for example try this in the python repl:print('%r, %r' % (sys.maxint, sys.maxint+1))
and notice theL
after the number.
– Eric
Nov 13 at 19:20
Well I did learn something new then. I did not realize that python natively handled larger than long values. Nice.
– David Parks
Nov 13 at 21:42
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
20
down vote
accepted
Take a look at itertools.count().
From the docs:
count(start=0, step=1)
--> count object
Make an iterator that returns evenly spaced values starting with
n
.
Equivalent to:
def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 ...
# count(2.5, 0.5) -> 2.5 3.0 3.5 ...
n = start
while True:
yield n
n += step
So for example:
import itertools
for i in itertools.count(13):
print(i)
would generate an infinite sequence starting with 13, in steps of +1. And, I hadn't tried this before, but you can count down too of course:
for i in itertools.count(100, -5):
print(i)
starts at 100, and keeps subtracting 5 for each new value ....
1
Beat me to it...
– jamylak
Jul 11 '12 at 2:45
1
@jamylak got lucky:)
– Levon
Jul 11 '12 at 2:45
I just couldn't stand the SO auto code formatter incorrect colors :)
– jamylak
Jul 11 '12 at 3:38
add a comment |
up vote
20
down vote
accepted
Take a look at itertools.count().
From the docs:
count(start=0, step=1)
--> count object
Make an iterator that returns evenly spaced values starting with
n
.
Equivalent to:
def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 ...
# count(2.5, 0.5) -> 2.5 3.0 3.5 ...
n = start
while True:
yield n
n += step
So for example:
import itertools
for i in itertools.count(13):
print(i)
would generate an infinite sequence starting with 13, in steps of +1. And, I hadn't tried this before, but you can count down too of course:
for i in itertools.count(100, -5):
print(i)
starts at 100, and keeps subtracting 5 for each new value ....
1
Beat me to it...
– jamylak
Jul 11 '12 at 2:45
1
@jamylak got lucky:)
– Levon
Jul 11 '12 at 2:45
I just couldn't stand the SO auto code formatter incorrect colors :)
– jamylak
Jul 11 '12 at 3:38
add a comment |
up vote
20
down vote
accepted
up vote
20
down vote
accepted
Take a look at itertools.count().
From the docs:
count(start=0, step=1)
--> count object
Make an iterator that returns evenly spaced values starting with
n
.
Equivalent to:
def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 ...
# count(2.5, 0.5) -> 2.5 3.0 3.5 ...
n = start
while True:
yield n
n += step
So for example:
import itertools
for i in itertools.count(13):
print(i)
would generate an infinite sequence starting with 13, in steps of +1. And, I hadn't tried this before, but you can count down too of course:
for i in itertools.count(100, -5):
print(i)
starts at 100, and keeps subtracting 5 for each new value ....
Take a look at itertools.count().
From the docs:
count(start=0, step=1)
--> count object
Make an iterator that returns evenly spaced values starting with
n
.
Equivalent to:
def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 ...
# count(2.5, 0.5) -> 2.5 3.0 3.5 ...
n = start
while True:
yield n
n += step
So for example:
import itertools
for i in itertools.count(13):
print(i)
would generate an infinite sequence starting with 13, in steps of +1. And, I hadn't tried this before, but you can count down too of course:
for i in itertools.count(100, -5):
print(i)
starts at 100, and keeps subtracting 5 for each new value ....
edited Jul 11 '12 at 3:32
jamylak
81k17173195
81k17173195
answered Jul 11 '12 at 2:45
Levon
82.7k22158161
82.7k22158161
1
Beat me to it...
– jamylak
Jul 11 '12 at 2:45
1
@jamylak got lucky:)
– Levon
Jul 11 '12 at 2:45
I just couldn't stand the SO auto code formatter incorrect colors :)
– jamylak
Jul 11 '12 at 3:38
add a comment |
1
Beat me to it...
– jamylak
Jul 11 '12 at 2:45
1
@jamylak got lucky:)
– Levon
Jul 11 '12 at 2:45
I just couldn't stand the SO auto code formatter incorrect colors :)
– jamylak
Jul 11 '12 at 3:38
1
1
Beat me to it...
– jamylak
Jul 11 '12 at 2:45
Beat me to it...
– jamylak
Jul 11 '12 at 2:45
1
1
@jamylak got lucky:)
– Levon
Jul 11 '12 at 2:45
@jamylak got lucky:)
– Levon
Jul 11 '12 at 2:45
I just couldn't stand the SO auto code formatter incorrect colors :)
– jamylak
Jul 11 '12 at 3:38
I just couldn't stand the SO auto code formatter incorrect colors :)
– jamylak
Jul 11 '12 at 3:38
add a comment |
up vote
0
down vote
This is a bit smaller code than what the other user provided!
x = 1
while True:
x = x+1
print x
I likecount
but this is also valid and can come in handy if you need multiple counters. Would update tox += 1
– CasualDemon
Oct 5 '17 at 21:04
add a comment |
up vote
0
down vote
This is a bit smaller code than what the other user provided!
x = 1
while True:
x = x+1
print x
I likecount
but this is also valid and can come in handy if you need multiple counters. Would update tox += 1
– CasualDemon
Oct 5 '17 at 21:04
add a comment |
up vote
0
down vote
up vote
0
down vote
This is a bit smaller code than what the other user provided!
x = 1
while True:
x = x+1
print x
This is a bit smaller code than what the other user provided!
x = 1
while True:
x = x+1
print x
edited Mar 20 '15 at 3:40
Nicholas
6,569144164
6,569144164
answered Mar 20 '15 at 2:49
paebak
91
91
I likecount
but this is also valid and can come in handy if you need multiple counters. Would update tox += 1
– CasualDemon
Oct 5 '17 at 21:04
add a comment |
I likecount
but this is also valid and can come in handy if you need multiple counters. Would update tox += 1
– CasualDemon
Oct 5 '17 at 21:04
I like
count
but this is also valid and can come in handy if you need multiple counters. Would update to x += 1
– CasualDemon
Oct 5 '17 at 21:04
I like
count
but this is also valid and can come in handy if you need multiple counters. Would update to x += 1
– CasualDemon
Oct 5 '17 at 21:04
add a comment |
up vote
0
down vote
A little shorter, using an iterator and no library:
x = 0
for x in iter(lambda: x+1, -1):
print(x)
But it requires a variable in the current scope.
add a comment |
up vote
0
down vote
A little shorter, using an iterator and no library:
x = 0
for x in iter(lambda: x+1, -1):
print(x)
But it requires a variable in the current scope.
add a comment |
up vote
0
down vote
up vote
0
down vote
A little shorter, using an iterator and no library:
x = 0
for x in iter(lambda: x+1, -1):
print(x)
But it requires a variable in the current scope.
A little shorter, using an iterator and no library:
x = 0
for x in iter(lambda: x+1, -1):
print(x)
But it requires a variable in the current scope.
answered Nov 10 at 23:40
Eric
445417
445417
add a comment |
add a comment |
up vote
-1
down vote
xrange
will give you an iterable object that won't use memory as you iterate, a for
loop is cleaner than a while
loop + counter if you ask me.
import sys
for i in xrange(0,sys.maxint):
print i
Not really infinite because it stops atsys.maxint
, after which the domain of thelong
integers start automagically.
– Eric
Nov 10 at 23:37
Not infinite, but "similar to i++ in other languages" though. And of course x=0, 1, 2... will overflow at the same point that this fails anyway, so the solution you have posed has the same limitation effectively. Truly infinite would have to use a big decimal style library that can store arbitrarily large values.
– David Parks
Nov 12 at 18:50
No solution I see here proposes anything that is capable of going pastsys.maxint
, so I contend that this is still the cleanest and clearest way to code this, under the assumption that one doesn't need more than9,223,372,036,854,775,807
loop iterations.
– David Parks
Nov 12 at 19:00
1
You're right it's a generator that is good enough in almost all practical cases, it's good way to cope with the practical problem. However it's limited to 2,147,483,647 on 32-bit machines, 2 giga is a reasonably achievable number in many applications. And it doesn't answer the question which is to make an infinite generator. Appart from that, you might not know that in python integers higher thansys.maxint
are supported natively and transparently via thelong
type, for example try this in the python repl:print('%r, %r' % (sys.maxint, sys.maxint+1))
and notice theL
after the number.
– Eric
Nov 13 at 19:20
Well I did learn something new then. I did not realize that python natively handled larger than long values. Nice.
– David Parks
Nov 13 at 21:42
add a comment |
up vote
-1
down vote
xrange
will give you an iterable object that won't use memory as you iterate, a for
loop is cleaner than a while
loop + counter if you ask me.
import sys
for i in xrange(0,sys.maxint):
print i
Not really infinite because it stops atsys.maxint
, after which the domain of thelong
integers start automagically.
– Eric
Nov 10 at 23:37
Not infinite, but "similar to i++ in other languages" though. And of course x=0, 1, 2... will overflow at the same point that this fails anyway, so the solution you have posed has the same limitation effectively. Truly infinite would have to use a big decimal style library that can store arbitrarily large values.
– David Parks
Nov 12 at 18:50
No solution I see here proposes anything that is capable of going pastsys.maxint
, so I contend that this is still the cleanest and clearest way to code this, under the assumption that one doesn't need more than9,223,372,036,854,775,807
loop iterations.
– David Parks
Nov 12 at 19:00
1
You're right it's a generator that is good enough in almost all practical cases, it's good way to cope with the practical problem. However it's limited to 2,147,483,647 on 32-bit machines, 2 giga is a reasonably achievable number in many applications. And it doesn't answer the question which is to make an infinite generator. Appart from that, you might not know that in python integers higher thansys.maxint
are supported natively and transparently via thelong
type, for example try this in the python repl:print('%r, %r' % (sys.maxint, sys.maxint+1))
and notice theL
after the number.
– Eric
Nov 13 at 19:20
Well I did learn something new then. I did not realize that python natively handled larger than long values. Nice.
– David Parks
Nov 13 at 21:42
add a comment |
up vote
-1
down vote
up vote
-1
down vote
xrange
will give you an iterable object that won't use memory as you iterate, a for
loop is cleaner than a while
loop + counter if you ask me.
import sys
for i in xrange(0,sys.maxint):
print i
xrange
will give you an iterable object that won't use memory as you iterate, a for
loop is cleaner than a while
loop + counter if you ask me.
import sys
for i in xrange(0,sys.maxint):
print i
edited Apr 7 '17 at 17:13
answered Apr 6 '17 at 4:32
David Parks
13.1k31108206
13.1k31108206
Not really infinite because it stops atsys.maxint
, after which the domain of thelong
integers start automagically.
– Eric
Nov 10 at 23:37
Not infinite, but "similar to i++ in other languages" though. And of course x=0, 1, 2... will overflow at the same point that this fails anyway, so the solution you have posed has the same limitation effectively. Truly infinite would have to use a big decimal style library that can store arbitrarily large values.
– David Parks
Nov 12 at 18:50
No solution I see here proposes anything that is capable of going pastsys.maxint
, so I contend that this is still the cleanest and clearest way to code this, under the assumption that one doesn't need more than9,223,372,036,854,775,807
loop iterations.
– David Parks
Nov 12 at 19:00
1
You're right it's a generator that is good enough in almost all practical cases, it's good way to cope with the practical problem. However it's limited to 2,147,483,647 on 32-bit machines, 2 giga is a reasonably achievable number in many applications. And it doesn't answer the question which is to make an infinite generator. Appart from that, you might not know that in python integers higher thansys.maxint
are supported natively and transparently via thelong
type, for example try this in the python repl:print('%r, %r' % (sys.maxint, sys.maxint+1))
and notice theL
after the number.
– Eric
Nov 13 at 19:20
Well I did learn something new then. I did not realize that python natively handled larger than long values. Nice.
– David Parks
Nov 13 at 21:42
add a comment |
Not really infinite because it stops atsys.maxint
, after which the domain of thelong
integers start automagically.
– Eric
Nov 10 at 23:37
Not infinite, but "similar to i++ in other languages" though. And of course x=0, 1, 2... will overflow at the same point that this fails anyway, so the solution you have posed has the same limitation effectively. Truly infinite would have to use a big decimal style library that can store arbitrarily large values.
– David Parks
Nov 12 at 18:50
No solution I see here proposes anything that is capable of going pastsys.maxint
, so I contend that this is still the cleanest and clearest way to code this, under the assumption that one doesn't need more than9,223,372,036,854,775,807
loop iterations.
– David Parks
Nov 12 at 19:00
1
You're right it's a generator that is good enough in almost all practical cases, it's good way to cope with the practical problem. However it's limited to 2,147,483,647 on 32-bit machines, 2 giga is a reasonably achievable number in many applications. And it doesn't answer the question which is to make an infinite generator. Appart from that, you might not know that in python integers higher thansys.maxint
are supported natively and transparently via thelong
type, for example try this in the python repl:print('%r, %r' % (sys.maxint, sys.maxint+1))
and notice theL
after the number.
– Eric
Nov 13 at 19:20
Well I did learn something new then. I did not realize that python natively handled larger than long values. Nice.
– David Parks
Nov 13 at 21:42
Not really infinite because it stops at
sys.maxint
, after which the domain of the long
integers start automagically.– Eric
Nov 10 at 23:37
Not really infinite because it stops at
sys.maxint
, after which the domain of the long
integers start automagically.– Eric
Nov 10 at 23:37
Not infinite, but "similar to i++ in other languages" though. And of course x=0, 1, 2... will overflow at the same point that this fails anyway, so the solution you have posed has the same limitation effectively. Truly infinite would have to use a big decimal style library that can store arbitrarily large values.
– David Parks
Nov 12 at 18:50
Not infinite, but "similar to i++ in other languages" though. And of course x=0, 1, 2... will overflow at the same point that this fails anyway, so the solution you have posed has the same limitation effectively. Truly infinite would have to use a big decimal style library that can store arbitrarily large values.
– David Parks
Nov 12 at 18:50
No solution I see here proposes anything that is capable of going past
sys.maxint
, so I contend that this is still the cleanest and clearest way to code this, under the assumption that one doesn't need more than 9,223,372,036,854,775,807
loop iterations.– David Parks
Nov 12 at 19:00
No solution I see here proposes anything that is capable of going past
sys.maxint
, so I contend that this is still the cleanest and clearest way to code this, under the assumption that one doesn't need more than 9,223,372,036,854,775,807
loop iterations.– David Parks
Nov 12 at 19:00
1
1
You're right it's a generator that is good enough in almost all practical cases, it's good way to cope with the practical problem. However it's limited to 2,147,483,647 on 32-bit machines, 2 giga is a reasonably achievable number in many applications. And it doesn't answer the question which is to make an infinite generator. Appart from that, you might not know that in python integers higher than
sys.maxint
are supported natively and transparently via the long
type, for example try this in the python repl: print('%r, %r' % (sys.maxint, sys.maxint+1))
and notice the L
after the number.– Eric
Nov 13 at 19:20
You're right it's a generator that is good enough in almost all practical cases, it's good way to cope with the practical problem. However it's limited to 2,147,483,647 on 32-bit machines, 2 giga is a reasonably achievable number in many applications. And it doesn't answer the question which is to make an infinite generator. Appart from that, you might not know that in python integers higher than
sys.maxint
are supported natively and transparently via the long
type, for example try this in the python repl: print('%r, %r' % (sys.maxint, sys.maxint+1))
and notice the L
after the number.– Eric
Nov 13 at 19:20
Well I did learn something new then. I did not realize that python natively handled larger than long values. Nice.
– David Parks
Nov 13 at 21:42
Well I did learn something new then. I did not realize that python natively handled larger than long values. Nice.
– David Parks
Nov 13 at 21:42
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11424808%2feasy-way-to-keep-counting-up-infinitely%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Also, why doesn't Python have i++? Literally every other language I've worked in does, and it seems like a glaring hole.
– Andrew Alexander
Jul 11 '12 at 2:49
6
1)
i++
is syntactic sugar and I doubt that you can call it's exclusion a "glaring hole". 2) Python usesi += 1
because it is more explicit about the increment. 3) Guido decided it was so.– Joel Cornett
Jul 11 '12 at 2:51
2
i+=1 is only one more character
– user485498
Jul 11 '12 at 2:51
4
@AndrewAlexander "There should be one-- and preferably only one --obvious way to do it."
– jamylak
Jul 11 '12 at 2:53