What is the Python equivalent to the .NET 'char' and 'byte' types ? I need to pass in an array of bytes to a .NET constructor and when I attempted to pass in a list of strings of single characters, it failed. Is there a way of doing this in PythonDotNet ?
Hi Edward - A Python string object or unicode object should convert to char[] automatically. Right now, the Byte converter expects to convert an int rather than a string, so a workaround might be to convert your list of strings to a list of ints to pass to the constructor: stuff = ['s', 't', 'u', 'f', 'f'] asint = map(ord, stuff) # pass asint to the constructor Hope this helps - I'll add a tracker issue that the converter should probably be smart enough to convert a string to a byte array by itself... Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com -----Original Message----- From: pythondotnet-bounces@python.org [mailto:pythondotnet-bounces@python.org]On Behalf Of Edward Diener Sent: Monday, February 07, 2005 1:54 PM To: pythondotnet@python.org Subject: [Python.NET] .NET character and byte What is the Python equivalent to the .NET 'char' and 'byte' types ? I need to pass in an array of bytes to a .NET constructor and when I attempted to pass in a list of strings of single characters, it failed. Is there a way of doing this in PythonDotNet ?
participants (2)
-
Brian Lloyd
-
Edward Diener