Ricky Teachey writes:
Continuing on with Steven's counter proposal and the motivating example of symbolic math, for multiple symbols it would be this:
# x, y, z = symbols( 'x,y,z' ) x, y, z = symbols(@@)
However, even though it works for the symbols example, this meaning looks odd to me:
# x, y, z = symbols( 'x,y,z' )
...it seems like this should in fact be *three separate assignment operations*, not a single assignment operation.
I don't think so. AFAIK, that syntax is not three separate assignment statments, conceptually: it's a tuple construction followed by destructuring assignment. That is, it's the problem of symbols() to return a compatible tuple.
This version also works for the symbols example, though it calls the factory function 3 times rather than 1. Is that an important downside?
Even if we interpret it as three assignments, I don't think so. Internally, it has to call Symbol() three times anyway, and you save a @@.split() call.
The other possibility would be to interpret
x, y, z = symbols(@@)
x, y, z = symbols('x', 'y', 'z')
SymPy can change this API, or add a new one, to be compatible with the googly eyes feature. The hardest part would be coming up with a name if a new API was the route chosen. SymPy users would adopt by acclamation, I think. The problem with this is that this doesn't work for anything but sequences, although I'm not sure how useful most other expressions on the lhs are anyway.
I am on the fence for the better meaning of this:
x = y = z = symbols(@@)
I think this already has a meaning:
x = y = (z := symbols(@@))
You could change it, of course, but I'd WTF every time I'm afraid. For the symbols() application, I'm much more sympathetic to the
x, y, z = symbols(@@)
syntax, most likely with the str value of @@ constructed in a canonical way from the AST as Chris suggests. SymPy can adapt or not as it chooses.
Bikeshed: we could put a nail in the coffin of "from __future__ import barry_as_flufl" using "<>" as the RHS token instead of googly eyes. (0.5 wink -- I realized the implication for barry_as_flufl only after thinking of this alternative.) I'd kinda like to save @@ for some hypothetical matrix operation.