[Python-bugs-list] [ python-Bugs-511603 ] Error calling str on subclass of int
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 31 Jan 2002 23:31:11 -0800
Bugs item #511603, was opened at 2002-01-31 23:31
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=511603&group_id=5470
Category: Type/class unification
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Nicholas Socci (nsocci)
Assigned to: Nobody/Anonymous (nobody)
Summary: Error calling str on subclass of int
Initial Comment:
Not sure if this is a bug or my misunderstanding of
str() and repr(). This work:
class Bfloat(float):
def __repr__(self):
return(str(self))
bf=Bfloat(1.0)
print bf
so does subclassing long, float, and str
but the following causes and infinite recursion
class Bint(int):
def __repr__(self):
return(str(self))
bi = Bint(1)
Version Info:
Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license" for more
information.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=511603&group_id=5470