[Python.NET] .NET character and byte

Brian Lloyd brian at zope.com
Tue Feb 8 16:50:29 CET 2005

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
might be to convert your list of strings to a list of ints to pass to the

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 at zope.com
V.P. Engineering   540.361.1716
Zope Corporation   http://www.zope.com

  -----Original Message-----
  From: pythondotnet-bounces at python.org
[mailto:pythondotnet-bounces at python.org]On Behalf Of Edward Diener
  Sent: Monday, February 07, 2005 1:54 PM
  To: pythondotnet at 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 ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythondotnet/attachments/20050208/7a0e4d5e/attachment.html

More information about the PythonDotNet mailing list