Skip to content
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

Shorthand for Tuple and Optional #151

Closed
DRayX opened this issue Aug 1, 2015 · 1 comment
Closed

Shorthand for Tuple and Optional #151

DRayX opened this issue Aug 1, 2015 · 1 comment

Comments

@DRayX
Copy link

DRayX commented Aug 1, 2015

Tuple and Optional will are used very frequently in my experimentation. Similar to allowing None in place of NoneType, it would be nice to have some shorthand expression for these types. As a possible suggestion, a tuple of types should be treated as Tuple, that is (int, str) would be equivalent to Tuple[int, str]. A set of a single type could be treated as an optional of that type, that is {int} would be equivalent to Optional[int].

@gvanrossum
Copy link
Member

Sorry, no. The tuple syntax was proposed multiple times in the discussions leading up to the PEP and rejected. Plain tuples like (int, str) have so many uses already that adding yet another use feels too much; and others have proposed them as a union shortcut, so it's apparently not obvious to everyone what they should mean. The {int} proposal is new but too arbitrary (why doesn't it mean Set[int]?).

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

No branches or pull requests

2 participants