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()

    where, consequently, ip, netmask, gateway_ip and dns are strings and mac is a sequence of 6 bytes (as reported in the doc).

    Finally if you want to convert your mac to hex format you can use something like this:

    hex_mac = '-'.join([ hex(xx, prefix='') for xx in mac ])

    Lorenzo Rizzello
    Zerynth Support Team

  • Thanks Lorenzo, works fine.
Sign In or Register to comment.

ZERYNTH Community

@ 2016, all rights reserved.