Skip to content

Support comma delimited string for namedtuple. #1518

Closed

Description

@graingert
from collections import namedtuple

X = namedtuple('X', 'a, b')
x = X(1, 'x')
x = X(b='y', a='x')  # error: Unexpected keyword argument "a" for "X"
x.a + [1]  # error: "X" has no attribute "a"
class Y(X): 
    """you can use a namedtuple class as a base class"""

Activity

  1. The-Compiler commented on May 11, 2016

    @The-Compiler
    Contributor

    #529 is the same thing for enum.Enum.

  2. added this to the milestone on Aug 18, 2016
  3. elazarg commented on Aug 31, 2016

    @elazarg
    Contributor

    I will add it to PR #1810, although it's easy enough not to wait for it. It requires a single line change here. Changing items = str_expr.value.split() into items = str_expr.value.replace(',', ' ').split()

    However, as discussed in the Enum case, it's a good idea not to use this form.

  4. elazarg commented on Sep 3, 2016

    @elazarg
    Contributor

    This has been be fixed by #1810

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions