Passing an object through COM which acts like str but isn't

Rafe rafesacks at
Fri Aug 15 15:35:55 CEST 2008

Forgive me if I mangle any terminology here, but please correct me if
I do...

I have an object which acts exactly like a string as long as I stay in
Python land. However, I am using the object in Softimage|XSI a 3D
application on Windows. It was created while (briefly) owned by
Microsoft, so knowledge of COM with excel or anything else should be
applicable I should think. I should also say I am a COM novice and
still learning Python (there are few that aren't learning though I

Here is an example:

class Name(object):
	def __init__(self, s): self.__data = s
	def __repr__(self): return repr(self.__data)
	def __cmp__(self, string): return cmp(self.__data, string)
	def __contains__(self, char): return char in self.__data

	__data = "Test"
	__doc  = "Test"
	def __Set(self, value):
		self.__data = value

	def __Get(self):
		return self.__data

	data = property(fget = __Get,
					fset = __Set,
					fdel = None,
					doc  = "string-like example")
 It also uses some new-style class Property

More information about the Python-list mailing list