Oct-30-2017, 09:58 AM
I have been given some example code that captures BLE broadcasts from beacons but there's a line that is really confusing me:
I just don't understand the syntax.
I think this is a 'list comprehension' but the explanations I have found are addling my noodle. How would this expand into a normal, sane 'for loop'?
data = [b for b in device.data]device.data is a list that contains BLE broadcast data from the bluetooth.get_adv() MicroPython function. It can hold up to 16 devices.
I just don't understand the syntax.
b
is not used anywhere and I don't get what b for b
is actually doing, especially since it isn't defined anywhere.I think this is a 'list comprehension' but the explanations I have found are addling my noodle. How would this expand into a normal, sane 'for loop'?