I’m having trouble running the examples in the TPython documentation page. I create a file called MyPyClass.py:
[code]print 'creating class MyPyClass … ’
class MyPyClass:
def init( self ):
print ‘in MyPyClass.init’
def gime( self, what ):
return what
[/code]
and, then run ROOT (5.26/00b) and do:
mwilliam@lxplus303:~/ > root -l
root [0] TPython::LoadMacro( "MyPyClass.py" );
creating class MyPyClass ...
root [1] MyPyClass m;
in MyPyClass.__init__
root [2] char* s = m.gime( "aap" );
root [3] s
(char* 0x3057140)"D@��*"
As you can see this is not returning “aap” but rather a random (presumably Unicode-type) string. In fact if I run the whole sequence again I get a different result of “�?)�S” or “�_��^” etc.
Given that I am running the example exactly as it is written I can’t see why this isn’t working. I’ve tried saving the .py file with different encodings such as UTF-8 and ASCII but it doesn’t seem to make a difference. Does anyone have any idea why this might be happening?
Thanks.