unittest.py: what is TestResult.__repr__ ?

Cromwell, Jeremy jcromwell at ciena.com
Fri Mar 15 15:20:57 EST 2002


>From the Python Reference Manual:
Section 3.3.1 Basic customization 
__repr__(self) 
Called by the repr() built-in function and by string conversions (reverse
quotes) to compute the ``official'' string representation of an object. If
at all possible, this should look like a valid Python expression that could
be used to recreate an object with the same value (given an appropriate
environment). If this is not possible, a string of the form "<...some useful
description...>" should be returned. The return value must be a string
object. 
This is typically used for debugging, so it is important that the
representation is information-rich and unambiguous. 

>From the Python Library Reference:
Section 2.1 Built-in Functions 
repr(object) 
Return a string containing a printable representation of an object. This is
the same value yielded by conversions (reverse quotes). It is sometimes
useful to be able to access this operation as an ordinary function. For many
types, this function makes an attempt to return a string that would yield an
object with the same value when passed to eval(). 

-Jeremy Cromwell, today's language lawyer

-----Original Message-----
From: quadzero at users.sourceforge.net
[mailto:quadzero at users.sourceforge.net]
Sent: Friday, March 15, 2002 11:41 AM
To: python-list at python.org
Subject: unittest.py: what is TestResult.__repr__ ?


I'm not a Python programmer (at least, not yet ;)

I am, however, trying to port the unittest.py framework to another
language.  Of all the languages that this testing framework has been
ported to, I thought that Python would be the easiest for me to
decipher.  For the most part, it seems pretty straightforward, except
for...

I'm presently stuck in the TestResult class.  Though I've searched for
the meaning of "__repr__" in the Python22 documentation, I cannot find
it.

Please help me understand this this convention of using leading and/or
trailing underscores in Python.

Thanks in advance...

Richard
-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list