Issue222788

classification
Title: Defining __str__ and __repr__ in java class (PR#111)
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: bckfnn
Priority: low Keywords:

Created on 2000-11-18.18:44:49 by bckfnn, last changed 2000-11-18.21:45:28 by bckfnn.

Messages
msg7 (view) Author: Finn Bock (bckfnn) Date: 2000-11-18.18:44:49
The __str__() and __repr__() in a java class are never called.

----------- FILE: test024j.java ----------- 

import org.python.core.*;

public class test024j {
    public PyObject __getitem__(PyObject key) {
        return new PyString("A __getitem__ string");
    }
    public PyString __repr__() {
        return new PyString("A __repr__ string");
    }
    public PyString __str__() {
        return new PyString("A __str__ string");
    }
}

----------- END ----------- 

JPython 1.1alpha3 on java1.2.1
Copyright 1997-1999 Corporation for National Research Initiatives
>>> import test024j
>>> t = test024j()
>>> print t
test024j@d9929d72
>>> print str(t)
test024j@d9929d72
>>> print repr(t)
test024j@d9929d72
>>>
msg8 (view) Author: Finn Bock (bckfnn) Date: 2000-11-18.21:45:28
I do not any longer think that this is a bug. A java instance can use toString to control its representation instead.
History
Date User Action Args
2000-11-18 18:44:49bckfnncreate