[Pyrex] Issue with strings (when working interactively)
Yuriy Pasichnyk
yuriy.pasichnyk at tridion.com
Thu Dec 16 12:02:04 CET 2004
Dear Sirs,
Could you possibly point me where I should look regarding the following
issue:
Let's say I have the following in my spam.pyx file:
#------------------------------------------------------
cdef class Test:
cdef char *x
def __new__(self):
self.x = ''
def setx(self, object v):
self.x = v
def __repr__(self):
return 'Test(' + self.x + ')'
#------------------------------------------------------
Now, if I call setx method of class test from a script test.py everything
works fine (see content of test.py below)
#-------------------------------------------------------
from spam import *
x = Test()
print x
x.setx("Hello !!!")
print x
x.setx("God day, isn't it?")
print x
#-------------------------------------------------------
Output:
#-------------------------------------------------------
Test('')
Test('Hello !!!')
Test("God day, isn't it?")
#-------------------------------------------------------
But when I work interactively by typing commands in Python interpreter
things go wrong (see below - marked in red)
#-------------------------------------------------------
ActivePython 2.3.4 Build 233 (ActiveState Corp.) based on
Python 2.3.4 (#53, Oct 18 2004, 20:35:07) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from spam import *
>>> x = Test()
>>> print x
Test('')
>>> x.setx('Hello !!!')
>>> print x
Test('\xd0\x15\x8e')
#-------------------------------------------------------
Any ideas what might go wrong?
Thanks in advance for your help,
Yuriy Pasichnyk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20041216/a8a406eb/attachment.html
More information about the Pyrex
mailing list