Unpacking the wifi.link_info() tuple?


Has anybody got an example of how to unpack and print the wifi.link_info() tuple.
I’m having problems because of my lack of knowledge of Python, I think.
The individual elements of the tuple are getting split by the “.” in the ip string.
Any help would be appreciated.


Hi kenr,
to unpack a tuple in Python you just need an assignment, in this case:

ip, netmask, gateway_ip, dns, mac = wifi.link_info()
<p>where, consequently, ip, netmask, gateway_ip and dns are strings and mac is a sequence of 6 bytes (as reported in the doc).</p><p>Finally if you want to convert your mac to hex format you can use something like this:</p><pre class=" CodeBlock">hex_mac = '-'.join([ hex(xx, prefix='') for xx in mac ])<br>


Thanks Lorenzo, works fine.