On 1 Jun 2016, at 18:14, Steven D'Aprano email@example.com wrote:
On Tue, May 31, 2016 at 01:09:05PM -0300, Alan Cristhian wrote:
The fundamental use-case here is "any object that needs to know its own name". Most objects need more than just a name.
A more general solution could be:
def x, y, z as <expression>
Where <expression> should return a callable that accept only one argument.
You should consider how your suggestion will work with the existing use-cases already shown.
We've got two dead-simple use-cases to consider. If this proposal makes those use-cases harder than the status quo, then this proposal is dead in the water. Nobody is going to use it.
# Status quo. T = Typevar('T') x = sympy.Symbol('x')
# My proposal. T -> Typevar() x -> sympy.Symbol()
# Your proposal. def T as (lambda: Typevar)() def x as (lambda: sympy.Symbol)()
Correct me if I'm wrong, but wouldn't it be
def T as Typevar
Unless you're being (rightfully) pedantic about "must return" implying that the expression will be called as a 0-argument function and that result called with the name?
You specify that the expression on the right must return a function that takes one variable, so you cannot use Typevar or Symbol directly. You have to call a function that returns the function you actually want.
Syntactic sugar is supposed to make things easier, not harder.
-- Steve _______________________________________________ Python-ideas mailing list Pythonfirstname.lastname@example.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/