Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Within IronPython 2.7, I am running a few calls to a .Net dll :

from System.Guid import NewGuid, ToByteArray
from System import Array, Byte
import clr
clr.AddReferenceToFile( ThePathToDLLFile )
from MyDLL import *
...
g = NewGuid()
buffer = ToByteArray(g)
ret = myDllMethodToFillBuffer( buffer )

Some methods like 'myDllMethod' return a buffer of type Array[byte]:

>>> type(buffer)
<type 'Array[Byte]'>

I am strugling to find the right way to convert the Array[byte] to Python 'string byte', IE '\x01\x02\x03 ...'

After a bit of googling I found the way to do the opposite conversion (string byte to byte[array])

byteArray = Array[Byte](ord(c) for c in byteList)

How should I convert a variable length byte[array] to string byte?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.