Request Help With Byte/String Problem

Wildman best_lay at
Thu Dec 1 22:16:17 EST 2016

On Wed, 30 Nov 2016 14:39:02 +0200, Anssi Saari wrote:

> There'll be a couple more issues with the printing but they should be
> easy enough.

I finally figured it out, I think.  I'm not sure if my changes are
what you had in mind but it is working.  Below is the updated code.
Thank you for not giving me the answer.  I was a good learning
experience for me and that was my purpose in the first place.

def format_ip(addr):
    return str(int(addr[0])) + '.' + \ # replace ord() with int()
           str(int(addr[1])) + '.' + \
           str(int(addr[2])) + '.' + \

ifs = all_interfaces()
for i in ifs:         # added decode("utf-8")
    print("%12s   %s" % (i[0].decode("utf-8"), format_ip(i[1])))

Thanks again!

<Wildman> GNU/Linux user #557453
May the Source be with you.

More information about the Python-list mailing list