[Python-ideas] ___repr__ on collections.UserDict, collections.UserList, collections.UserString

David Kendal me at dpk.io
Mon Sep 19 07:05:27 EDT 2016


Hi,

  the UserDict, UserList, and UserString classes in the collections
module ought to provide __repr__ implementations along the following
lines:

def __repr__(self):
    return '%s(%r)' % (type(self).__name__, self.data)

so that they give useful immediate information in the repl to the
effect that they are not mere dicts/lists/strs but user-defined
container types.

dpk (David P. Kendal) · Nassauische Str. 36, 10717 DE · http://dpk.io/
 The reason we had no idea how cats worked was because, since Newton,
 we had proceeded by the simple principle that essentially, to see how
 things work, we took them apart. If you try and take a cat apart to
 see how it works, the first thing you have on your hands is a non-
 working cat.                                   -- Douglas Adams



More information about the Python-ideas mailing list