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

Disallow List[int] etc. as expressions #556

Closed
JukkaL opened this issue Jan 17, 2015 · 1 comment
Closed

Disallow List[int] etc. as expressions #556

JukkaL opened this issue Jan 17, 2015 · 1 comment

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jan 17, 2015

The current PEP 484 draft does not allow writing code like this:

x = List[int]()

Instead, the recommended way is using type annotations:

x = [] # type: List[int]
# or
y = Undefined(List[int])
y = []

See also: python/typing#9

@gvanrossum
Copy link
Member

(The PEP went back and forth a few times; Undefined was removed. Right now the PEP suggests using either a # type comment or defining an alias, e.g. IntList = List[int] after which you can say y = IntList().)

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

2 participants