[Python-ideas] Quick idea: defining variables from functions that take the variable name

Guido van Rossum guido at python.org
Mon May 30 21:16:26 EDT 2016

In mypy we have a need for type variables, which are created like this:

  from typing import TypeVar

  T = TypeVar('T')

I just saw a lightning talk about sympy where they define symbols to
be used in mathematical equations, like this:

  from sympy import Symbol

  x = Symbol('x')

I'm sure this is not a new idea, but so far I've always thought that
this is pretty esoteric and the approach here is good enough. But
maybe we can actually do better, and whatever solution we come up with
might also be useful for extracting attributes from an object or
values from a mapping?

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list