Article 5JVYJ [$] When and how to evaluate Python annotations

[$] When and how to evaluate Python annotations

by
jake
from LWN.net on (#5JVYJ)
Annotations in Python came late to the party; they were introduced inPython 3 as a way to attach information to functions describing their arguments andreturn values. While that mechanism had obvious applications for addingtype information to Python functions, standardized interpretations for theannotations came later with type hints.But evaluating the annotations at function-definition time caused somedifficulties, especially with respect to forward references to type names,so a Python Enhancement Proposal (PEP) was created to postpone theirevaluation until they were needed. The PEP-described behavior was set tobecome the default in the upcoming Python 3.10 release, but that isnot to be; the postponement of evaluation by default has itself been postponed in thehopes of unwinding things.
External Content
Source RSS or Atom Feed
Feed Location http://lwn.net/headlines/rss
Feed Title LWN.net
Feed Link https://lwn.net/
Reply 0 comments