Issue629217
Created on 2002-10-26.20:11:00 by ype, last changed 2005-06-13.11:56:17 by bzimmer.
File name |
Uploaded |
Description |
Edit |
Remove |
strforjarray.txt
|
ype,
2002-10-26.20:11:00
|
Patch diff -c, 4 added lines |
|
|
msg2260 (view) |
Author: Ype (ype) |
Date: 2002-10-26.20:11:00 |
|
Implemented method __str__() on PyArray, using the
tostring() method that was already there. Left tostring() for
backwards compatibility.
I have not yet figured out how to add this to the docs of
jarray.
In case this needs more testing than interactive, let me
know.
|
msg2261 (view) |
Author: Samuele Pedroni (pedronis) |
Date: 2005-01-09.19:29:31 |
|
Logged In: YES
user_id=61408
this a bit controversial, because CPython itself does
>>> str(array.array('c','xbc'))
"array('c', 'xbc')"
but if I remember the discussion it is valuable to it.
But as it is I think it break str for non chars array,
there's should be an if to fallback to repr form
for those cases.
|
msg2262 (view) |
Author: Samuele Pedroni (pedronis) |
Date: 2005-01-09.19:30:48 |
|
Logged In: YES
user_id=61408
s/valuable to it/valuable to go for it/
|
msg2263 (view) |
Author: Brian Zimmer (bzimmer) |
Date: 2005-02-20.20:30:36 |
|
Logged In: YES
user_id=37674
Why is Jython choosing to differentiate from CPython in this regard? The
CPython value is as Sameule wrote, with the Jython version flipping the
order of type and values as well as spelling the type out rather than
having the single character.
|
msg2264 (view) |
Author: Ype (ype) |
Date: 2005-02-20.22:58:09 |
|
Logged In: YES
user_id=125722
It's been a while, but the original problem was to get a python
string from a java character buffer. I had to actually go to
the source code of jarray to find the tostring() method
in the first place. I remember trying str() and that wouldn't
work.
So, the point was not to implement str(), but to have
a straightforward way to get from a java character buffer to
a python string; str() seemed like a good way to do that,
but any other (preferably documented) way could be good.
What is the CPython way to get a python string from a
character buffer? str() seems to return too much there.
Kind regards,
Ype
|
msg2265 (view) |
Author: Clark Updike (cupdike) |
Date: 2005-06-13.03:08:31 |
|
Logged In: YES
user_id=775310
I don't think str() should call tostring() because that is
not what
cpython does. But PyArray should be changed so that str()
outputs the typecode first. The real goal is as follows:
Python 2.2.3 (#42, May 30 2003, 18:12:08)
Type "help", "copyright", "credits" or "li
>>> from array import array
>>> x=array('c',"abcde")
>>> x == eval(str(x))
1
Currently, this produces "NameError: char". Unless I hear
otherwise from someone, I'll set this to Closed--Rejected
and implement the requisite changes.
|
msg2266 (view) |
Author: Ype (ype) |
Date: 2005-06-13.06:49:49 |
|
Logged In: YES
user_id=125722
I finally got the point that tostring() is also the CPython
way to get from a character array to a python string:
http://docs.python.org/lib/module-array.html
and I agree to reject the original patch.
Thanks for looking into this,
Kind regards,
Ype
|
msg2267 (view) |
Author: Brian Zimmer (bzimmer) |
Date: 2005-06-13.11:56:17 |
|
Logged In: YES
user_id=37674
I agree to reject this as well and fix as suggested by Clark.
thanks, brian
|
|
Date |
User |
Action |
Args |
2002-10-26 20:11:00 | ype | create | |
|