8000 Support default values for collections.namedtuple? · Issue #4788 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Support default values for collections.namedtuple? #4788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ilevkivskyi opened this issue Mar 24, 2018 · 3 comments
Closed

Support default values for collections.namedtuple? #4788

ilevkivskyi opened this issue Mar 24, 2018 · 3 comments

Comments

@ilevkivskyi
Copy link
Member

Python 3.7 adds support for specifying default values in call to collections.namedtuple, see python/cpython#4859. So for example this is valid:

from collections import namedtuple

NT = namedtuple('NT', ('x', 'y'), defaults=(0, 0))
NT()
NT(1)
NT(1, 2)

Should we support this, or supporting default values for typing.NamedTuple (already implemented) is enough?

@gvanrossum
Copy link
Member

The short form of collections.namedtuple is very popular (ask @rhettinger) and I think we should make it as easy as possible to translate its use to typing.NamedTuple. So I think we should support it.

@JukkaL
Copy link
Collaborator
JukkaL commented Mar 26, 2018

I agree with @gvanrossum. Also, this doesn't look like a lot of work to implement. Tagging as high priority since 3.7 release date is pretty close.

@JelleZijlstra
Copy link
Member

Fixed by #5215.

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

No branches or pull requests

4 participants
0