Re: Request Help With Byte/String Problem

2016-12-03 Thread Wildman via Python-list
On Fri, 02 Dec 2016 19:39:39 +, Grant Edwards wrote: > On 2016-12-02, Wildman via Python-list wrote: >> On Fri, 02 Dec 2016 15:11:18 +, Grant Edwards wrote: >> >>> I don't know what the "addr" array contains, but if addr is a byte >>> string, then the "int()" call

Re: Request Help With Byte/String Problem

2016-12-02 Thread Grant Edwards
On 2016-12-02, Wildman via Python-list wrote: > On Fri, 02 Dec 2016 15:11:18 +, Grant Edwards wrote: > >> I don't know what the "addr" array contains, but if addr is a byte >> string, then the "int()" call is not needed, in Pythong 3, a byte is >> already an integer:

Re: Request Help With Byte/String Problem

2016-12-02 Thread Wildman via Python-list
On Fri, 02 Dec 2016 15:11:18 +, Grant Edwards wrote: > I don't know what the "addr" array contains, but if addr is a byte > string, then the "int()" call is not needed, in Pythong 3, a byte is > already an integer: > > def format_ip(a): >return '.'.join(str(b) for b in a) > >

Re: Request Help With Byte/String Problem

2016-12-02 Thread Grant Edwards
On 2016-12-02, Wildman via Python-list wrote: > 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

Re: Request Help With Byte/String Problem

2016-12-01 Thread Wildman via Python-list
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

Re: Request Help With Byte/String Problem

2016-12-01 Thread Wildman via Python-list
On Wed, 30 Nov 2016 07:54:45 -0500, Dennis Lee Bieber wrote: > On Tue, 29 Nov 2016 22:01:51 -0600, Wildman via Python-list > declaimed the following: > >>I really appreciate your reply. Your suggestion fixed that >>problem, however, a new error appeared. I am doing

Re: Request Help With Byte/String Problem

2016-11-30 Thread Anssi Saari
Wildman via Python-list writes: > On Tue, 29 Nov 2016 18:29:51 -0800, Paul Rubin wrote: > >> Wildman writes: >>> names = array.array("B", '\0' * bytes) >>> TypeError: cannot use a str to initialize an array with typecode 'B' >> >> In Python 2,

Re: Request Help With Byte/String Problem

2016-11-29 Thread Wildman via Python-list
On Tue, 29 Nov 2016 18:29:51 -0800, Paul Rubin wrote: > Wildman writes: >> names = array.array("B", '\0' * bytes) >> TypeError: cannot use a str to initialize an array with typecode 'B' > > In Python 2, str is a byte string and you can do that. In Python 3, > str is a

Re: Request Help With Byte/String Problem

2016-11-29 Thread Paul Rubin
Wildman writes: > names = array.array("B", '\0' * bytes) > TypeError: cannot use a str to initialize an array with typecode 'B' In Python 2, str is a byte string and you can do that. In Python 3, str is a unicode string, and if you want a byte string you have to specify

Request Help With Byte/String Problem

2016-11-29 Thread Wildman via Python-list
For the purpose of learning I am writing a script that will return different information about the Linux machine where it is running. Sort of like the inxi utility. Below is some code that I found that returns a list of the network interface devices on the system. It runs as is perfectly on