
On 31 May 2016 at 04:08, Steven D'Aprano <steve@pearwood.info> wrote:
How do you feel about an arrow operator?
T -> TypeVar() x -> Symbol() T -> type(bases, ns) Record -> namedtuple(fields)
I like this. Simplifying it, how about name [, name ...] -> callable which is equivalent to name [, name ...] = callable(('name' [, 'name' ... ])) I.e., the RHS is a callable, and we call it with the names. No need to inject an argument into an existing call. This avoids any confusion over the RHS being "too complex". For callables that have extra arguments, just use functools.partial. I agree with the special case of a single name becoming a string (rather than a tuple of strings). If you want a 1-tuple, do "name, -> function" (the same trick as for unpacking assignment). As for the operator name, I like -> but I see why Guido might object because of the type signature usage (although is there actually any clash?) Alternatives could be := (from Pascal, although that doesn't have the implication of "sending the LHS to the right") or => (which might work, but is easily confused with >=/<=). If a 3-character symbol is acceptable, ->> might work. Keywords don't really sit right with me for this. Paul