MCPcopy Create free account
hub / github.com/bitcraze/crazyflie-lib-python / choose

Function choose

examples/flash-memory.py:110–129  ·  view source on GitHub ↗

Interactively choose one of the items.

(items, title_text, question_text)

Source from the content-addressed store, hash-verified

108
109
110def choose(items, title_text, question_text):
111 """
112 Interactively choose one of the items.
113 """
114 print(title_text)
115
116 for i, item in enumerate(items, start=1):
117 print('%d) %s' % (i, item))
118 print('%d) Abort' % (i + 1))
119
120 selected = input(question_text)
121 try:
122 index = int(selected)
123 except ValueError:
124 index = -1
125 if not (index - 1) in range(len(items)):
126 print('Aborting.')
127 return None
128
129 return items[index - 1]
130
131
132def scan():

Callers 2

scanFunction · 0.85
flash-memory.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected