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

Joseph Martinot-Lagarde contrebasse at gmail.com
Tue May 31 10:12:05 EDT 2016


Steven D'Aprano <steve at ...> writes:

> How do you feel about an arrow operator?
> 
> T -> TypeVar()
> x -> Symbol()
> T -> type(bases, ns)
> Record -> namedtuple(fields)
> 
> In general:
> 
> name [, name, ...] -> callable(...)
> 
> where "callable" is some expression, e.g. a name, a dot lookup, etc.
> 

It could work with indexing, like:

    key -> my_dict[]

instead of

    key = my_dict[key]



Or even attribute lookup with a trailing dot:

    attr -> my_object.

instead of

    attr = my_object.attr

Joseph




More information about the Python-ideas mailing list