tags:

views:

265

answers:

2

I'm using Python 2.5. The DLL I imported is created using the CLR. The DLL function is returning a string. I'm trying to apply "partition" attribute to it. I'm not able to do it. Even the partition is not working. I think "all strings returned from CLR are returned as Unicode". Help me please. It's very urgent.

Thank you Jetxee for your reply.It was helpful.I want to know another issue. The exact problem is the string that is being returned from VB .NET contains strings seperated with '\r'.But while reaching Python '|r' becomes '\\r'.So i was not getting the right string aftr conversion also.Now i managed by giving '\\r' in my split function.I want to know about this.

+2  A: 

Could you post your error message? Could you post what type of object you have (type(yourvar))?

Please check if you have a partition(sep) method for this object (dir(yourvar)).

Applying partition method should look like:

>>> us=u"Привет, Unicode String!"
>>> us.partition(' ')
(u'\u041f\u0440\u0438\u0432\u0435\u0442,', u' ', u'Unicode String!')

You can also try split function instead of partition:

>>> from string import split
>>> split(us,' ',1)
[u'\u041f\u0440\u0438\u0432\u0435\u0442,', u'Unicode String!']
jetxee
+1  A: 

If by CLR you mean .NET CLR, try using IronPython :

IronPython is a new implementation of the Python programming language running on .NET. It supports an interactive console with fully dynamic compilation. It is well integrated with the rest of the .NET Framework and makes all .NET libraries easily available to Python programmers, while maintaining full compatibility with the Python language.

In IronPython, loading (importing) and calling a .NET dll is well documented and straight forward.

gimel