2015-12-08 16:05:14 -05:00
|
|
|
# test for+range, mostly to check optimisation of this pair
|
|
|
|
|
|
|
|
# apply args using *
|
|
|
|
for x in range(*(1, 3)):
|
|
|
|
print(x)
|
|
|
|
for x in range(1, *(6, 2)):
|
|
|
|
print(x)
|
|
|
|
|
2017-04-04 20:52:29 -04:00
|
|
|
# zero step
|
|
|
|
try:
|
|
|
|
for x in range(1, 2, 0):
|
|
|
|
pass
|
|
|
|
except ValueError:
|
|
|
|
print('ValueError')
|
|
|
|
|
2015-12-08 16:05:14 -05:00
|
|
|
# apply args using **
|
|
|
|
try:
|
|
|
|
for x in range(**{'end':1}):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
for x in range(0, **{'end':1}):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
for x in range(0, 1, **{'step':1}):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
|
|
|
|
# keyword args
|
|
|
|
try:
|
|
|
|
for x in range(end=1):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
for x in range(0, end=1):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2016-10-10 21:30:32 -04:00
|
|
|
try:
|
|
|
|
for x in range(start=0, end=1):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
2015-12-08 16:05:14 -05:00
|
|
|
try:
|
|
|
|
for x in range(0, 1, step=1):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
|
|
|
|
# argument is a comprehension
|
|
|
|
try:
|
|
|
|
for x in range(0 for i in []):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
for x in range(0, (0 for i in [])):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
try:
|
|
|
|
for x in range(0, 1, (0 for i in [])):
|
|
|
|
print(x)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|