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

Greg Ewing greg.ewing at canterbury.ac.nz
Tue May 31 09:02:57 EDT 2016


> On 31 May 2016 at 04:08, Steven D'Aprano <steve at pearwood.info> wrote:
> 
>>T -> TypeVar()
>>x -> Symbol()
>>T -> type(bases, ns)
>>Record -> namedtuple(fields)

The arrow seems back to front. It should point towards
the name being assigned.

    T <- TypeVar()
    x <- Symbol()
    T <- type(bases, ns)
    Record <- namedtuple(fields)

Also, if the RHS is going to be called as part of
the <- operation, shouldn't the first two just be

    T <- TypeVar
    x <- Symbol

The main drawback is that '<-' doesn't suggest in any
way what's going on.

An alternative might be

    def x = Symbol

since 'def' has the precedent of attaching the name
being bound to the object being created.

-- 
Greg


More information about the Python-ideas mailing list