Re: [Python-ideas] Python-ideas Digest, Vol 140, Issue 169

2018-07-26 Thread James Lu
> I several times wished I could have had a reference to the block of code in a 
> `with` clause.

Could you abstractly describe a real-world example of this? I’d like to hear 
your use case. 

> The example for sorted is also kinda twisted.

It is, it’s probably a counterexample on how to use it.

I forgot to mention, could it be possible to only treat do as a keyword when 
it’s used in an as-do expression? So, do remains a legal variable name, and do 
is only interpreted as a keyword when it’s in an as-do expression. I believe 
this is possible using the Python grammar. 
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Python-ideas Digest, Vol 140, Issue 169

2018-07-26 Thread James Lu
> You mean lambda x: lumberjack(15, x) ?
Yes, that was my mistake.

>  However this syntax you allow to write lumberjack(%, 15) which is only
> possible with partial using keyword arguments, like lumberjack (y=15)
> (given that the second argument is called "y") and in that case I know at
> least one library on pip doing the job with Ellipsis :
> 
> from funcoperators import elipartial
> elipartial(lumberjack, ..., 15)
> # gives lambda x: lumberjack (x, 15)
> 
> elipartial (lumberjack, ..., 15, ..., 12, ...)
> # gives lambda x, y, z: lumberjack(x, 15, y, 12, z)
> 
> And the lib even provide a decorator to have that kind of syntax using "[" :
> 
> partially(lumberjack)[15]
> would be the same as partial(lumberjack, 15)
> 
> So, that functionality does really need new syntax.

Hm, yes. Perhaps elipartial could be aliased and/or made a global built in. 
Let’s discuss the merits of the statement itself then.
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/