Saw somebody was viewing this thread and thought the qrange needed one update. From post http://www.daniweb.com/code/snippet216627.html.
update of vegasets qrange
# qrange( [start,] stop[, step] ) is a generator, works similar to xrange()
def qrange(start, stop=None, step=1):
"""if start is missing it defaults to zero, somewhat tricky"""
start, stop = (0, start) if stop is None else (start, stop)
# allow for decrement
while start > stop if step<0 else start < stop:
yield start # makes this a generator for new start value
start += step
# test
print qrange(0, 10, 2) # <generator object at 0x009D5E68>
print list(qrange(0, 10, 2)) # [0, 2, 4, 6, 8]
print list(qrange(10,0, -1))
print list(qrange(0,10,-1))
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.