Re: [Tutor] byte array conversion question

2011-02-03 Thread Steven D'Aprano
Bill Allen wrote: I have found that there are a couple of ways to convert a byte array to a string in Python. Is there any advantage or disadvantage to either method? my_bytes = b'this is a test' str(my_bytes,'utf-8') yields 'this is a test' my_bytes.decode('utf-8';) yeilds 'this is a tes

[Tutor] byte array conversion question

2011-02-02 Thread Bill Allen
I have found that there are a couple of ways to convert a byte array to a string in Python. Is there any advantage or disadvantage to either method? my_bytes = b'this is a test' str(my_bytes,'utf-8') yields 'this is a test' my_bytes.decode('utf-8';) yeilds 'this is a test' --Bill

Re: [Tutor] byte[] array

2006-10-08 Thread Hugo González Monteverde
gert wohlgemuth wrote: > As anybody an idea how I can do this in python? I can think of three ways: Strings in Python can contain arbitrary binary values, so they can be used. If they're going to be modified often, you may use a list, or you may use the array module for performance. Are you s

Re: [Tutor] byte[] array

2006-10-03 Thread Kent Johnson
gert wohlgemuth wrote: > Hi, > > I'm used to java byte arrays (byte[]) and need the same type in python, > cause we have a couple of established web services, which return a byte[] or > take a byte[] as parameter. > > As anybody an idea how I can do this in python? A string can be used as a byte

[Tutor] byte[] array

2006-10-03 Thread gert wohlgemuth
Hi, I'm used to java byte arrays (byte[]) and need the same type in python, cause we have a couple of established web services, which return a byte[] or take a byte[] as parameter. As anybody an idea how I can do this in python? Thx, g. ___ Tutor mai