[Python-Dev] The purpose of the 'repr' builtin function
Peter Funk
pf@artcom-gmbh.de
Tue, 11 Apr 2000 12:15:20 +0200 (MEST)
Hi!
Currently the wrapper classes UserList und UserString contain the
following method:
def __repr__(self): return repr(self.data)
I wonder about the following alternatives:
def __repr__(self):
return self.__class__.__name__ + "(" + repr(self.data) + ")"
or even more radical (here only for lists as an example):
def __repr__(self):
result = [self.__class__.__name__, "("]
for item in self.data:
result.append(repr(item))
result.append(", ")
result.append(")")
return "".join(result)
Just a thought which jumped into my mind during the recent discussion
about the purpose of the 'repr' function (float representation).
Regards, Peter
--
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen)