News for hackers. Stuff that matters.
Re:Python 2 will be replaced with Python 3 in the next RHEL ... by jononor on Wednesday April 11, 2018 @05:39AM (#16809449)
Since Python 3.5 (3 years ago) type hints are part of the core syntax. Don't need to put them in comments. https://www.python.org/dev/peps/pep-0484/#type-definition-sy...
Re:Python 2 will be replaced with Python 3 in the next RHEL ... by oblio on Wednesday April 11, 2018 @06:00AM (#16809556)
They badly need to update the docs, then. Almost everything I see on that page does this:

vec = [] # type: Vector[float]

vec = [] # type: Iterable[Tuple[float, float]]

a = MyClass() # type: MyClass[int]

x = Foo() # type: Foo[int]

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by icegreentea2 on Wednesday April 11, 2018 @07:05AM (#16809845)
Ugh that's because PEP 484 (which introduced 'proper' type hints) only introduced it for parameters and return types and implemented in Python 3.5. Type hinting bare variables was introduced with PEP 526 and implemented in Python 3.6.

While I really like the concept of PEPs, and I think keeping original (like as they were written) PEPs around are the right thing to do, I do wish sometimes that Python did a better job at incorporating changes from PEPs into the core documentation once implemented.

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by tobltobs on Wednesday April 11, 2018 @05:46AM (#16809490)
> a_list = [] # type: List[T]

How do you do that with out a comment?

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by Chickenosaurus on Wednesday April 11, 2018 @05:56AM (#16809538)
from typing import List

a_list: List[T] = []

Visit https://docs.python.org/3/library/typing.html for more information.

Re:Python 2 will be replaced with Python 3 in the next RHEL ... by Osmium on Wednesday April 11, 2018 @05:54AM (#16809533)
> a_list: List[T] = []
Re:Python 2 will be replaced with Python 3 in the next RHEL ... by umanwizard on Wednesday April 11, 2018 @05:55AM (#16809537)
a_list: List[T] = []