[Python-ideas] Enabling / disabling optional type hinting

Stefan Krah skrah at bytereef.org
Sat Mar 23 13:59:19 EDT 2019


On Sat, Mar 23, 2019 at 10:37:43AM -0700, Gregory P. Smith wrote:
> A useless statement like that isn't likely to be typed.  I've never seen
> anyone do that.

Unlikely yes, but ideally type annotations should not alter program behavior:

>>> d = {}
>>> try: d["x"]
... except KeyError: print("KeyError")
... 
KeyError
>>> 
>>> d = {}
>>> try: d["x"] : int
... except KeyError: print("KeyError")
... 


Stefan Krah





More information about the Python-ideas mailing list