Message270981
The type objects constructed by the metaclasses in the typing module are hashable and comparable for equality:
>>> from typing import *
>>> {Mapping[str, int], Mapping[int, str]}
{typing.Mapping[int, str], typing.Mapping[str, int]}
>>> Union[str, int, float] == Union[float, int, str]
True
>>> List[int] == List[float]
False
but this is not clearly documented in the documentation for the typing module (there are a handful of examples using equality, but it's not explicit that these are runnable).
It would be nice if there were explicit documentation for these properties of type objects. |
|
Date |
User |
Action |
Args |
2016-07-22 09:50:51 | gdr@garethrees.org | set | recipients:
+ gdr@garethrees.org, docs@python |
2016-07-22 09:50:51 | gdr@garethrees.org | set | messageid: <1469181051.15.0.925508125369.issue27588@psf.upfronthosting.co.za> |
2016-07-22 09:50:51 | gdr@garethrees.org | link | issue27588 messages |
2016-07-22 09:50:50 | gdr@garethrees.org | create | |
|