[docs] [issue27588] Type objects are hashable and comparable for equality but this is not documented
Gareth Rees
report at bugs.python.org
Fri Jul 22 05:50:51 EDT 2016
New submission from Gareth Rees:
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.
----------
assignee: docs at python
components: Documentation
messages: 270981
nosy: Gareth.Rees, docs at python
priority: normal
severity: normal
status: open
title: Type objects are hashable and comparable for equality but this is not documented
type: enhancement
versions: Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27588>
_______________________________________
More information about the docs
mailing list