I am a total novice at Python, and have come across a piece of code that confuses me.
ts, pkt2 = capPort2.wait(1, 45)[0]
The previous line confuses me. I understand the call to the function wait
with the two parameters, but what does the [0]
mean or do?
It means to extract the first item in the list/tuple return by the function.
In [1]: "this is a long sentence".split()
Out[1]: ['this', 'is', 'a', 'long', 'sentence']
In [2]: "this is a long sentence".split()[0]
Out[2]: 'this'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With