Anonymous
public text v1 · immutabledef _get_selection(self, l, q = ""):
"Returns the index of a user selection out of sequence l"
selection = None
while selection is None:
if q:
print q
for i, obj in enumerate(l):
print i, l
try:
selection = int(raw_input(">>>"))
except ValueError:
print "I'm sorry, you didn't type a valid index"
else:
try:
l[selection]
except IndexError:
print "I'm sorry, you didn't type a valid index"
selection = None
return selection