New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 697996 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner: ----
Closed: Sep 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Task

Blocking:
issue 644372



Sign in to add a comment

[Predator] get rid of __str__ for namedtuple classes?

Project Member Reported by wrengr@chromium.org, Mar 2 2017

Issue description

I recently learned that the ``namedtuple`` class provides a definition of ``__str__`` which does the thing we usually want for debugging. For example, the class ``namedtuple('X', ['a', 'b', 'c'])`` has the method:

    def __str__(self):
        return "X(a = %s, b = %s, c = %s)" % (self.a, self.b, self.c)

Whenever we say ``class Y(namedtuple('X', ...))``, the class ``Y`` inherits ``X.__str__``; thus, so long as ``X`` and ``Y`` are textually the same name, the inherited method will do the right thing. In our code we always make sure the names match; thus, we could get rid of all our explicit ``Y.__str__`` method definitions.
 
Status: Fixed (was: Available)

Sign in to add a comment