[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread David Mertz
On Sat, Jul 27, 2019 at 9:28 PM Steven D'Aprano wrote: > If you're going to add support for a placeholder, there is no need to > create a new kind of partial function? > Exactly! This is just an enhanced functools.partial. An enhancement that has already been done in several 3rd party

[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread Andrew Barnert via Python-ideas
On Jul 27, 2019, at 12:47, Anders Hovmöller wrote: > > >> On 27 Jul 2019, at 21:10, Andrew Barnert wrote: >> >> Many of the compelling examples for PEP 570 are good examples here. The >> following are all impossible intentionally, and for different reasons: >> >> skipper = partial(range,

[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread Steven D'Aprano
On Sat, Jul 27, 2019 at 12:47:39PM -, Dominik Vilsmeier wrote: > I propose adding a function to `functools` that works with > placeholders and thus offers even greater flexibility. The Ellipsis > literal `...` seems a intuitive choice for that task. When eventually > calling such a

[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread Guido van Rossum
Before we go too far down this route, let's consider whether these can't be solved with lambda rather than introducing new special cases to partial(). -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him/his **(why is my pronoun here?)*

[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread MRAB
On 2019-07-27 20:10, Andrew Barnert via Python-ideas wrote: On Jul 27, 2019, at 08:04, Anders Hovmöller wrote: On 27 Jul 2019, at 14:47, Dominik Vilsmeier wrote: currently, regarding positional arguments, `partial` gives us the option to partialize functions from the left. There's been

[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread Anders Hovmöller
> On 27 Jul 2019, at 21:10, Andrew Barnert wrote: > > On Jul 27, 2019, at 08:04, Anders Hovmöller wrote: >> >>> On 27 Jul 2019, at 14:47, Dominik Vilsmeier >>> wrote: >>> >>> currently, regarding positional arguments, `partial` gives us the option to >>> partialize functions from the

[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread Andrew Barnert via Python-ideas
On Jul 27, 2019, at 08:04, Anders Hovmöller wrote: > >> On 27 Jul 2019, at 14:47, Dominik Vilsmeier wrote: >> >> currently, regarding positional arguments, `partial` gives us the option to >> partialize functions from the left. There's been some interest about >> partializing functions from

[Python-ideas] Re: Cartesian Product on `__mul__`

2019-07-27 Thread Ethan Furman
On 07/27/2019 03:17 AM, Batuhan Taskaya wrote: Its more clear and understandable than itertools.product for people from outside of a programming background. The simplicity is useful when we are working with multiple expressions at sametime. (cset(a & b) * cset(a | b)) So build that

[Python-ideas] Re: for ... except, with ... except

2019-07-27 Thread Ethan Furman
On 07/27/2019 01:19 AM, Serhiy Storchaka wrote: 26.07.19 23:57, Guido van Rossum пише: However, I worry that when people see this syntax, they will think that the except clause is for handling exceptions in the loop body. (That's certainly what I assumed when I read just your subject line.

[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread Anders Hovmöller
> On 27 Jul 2019, at 14:47, Dominik Vilsmeier wrote: > > Hello, > > currently, regarding positional arguments, `partial` gives us the option to > partialize functions from the left. There's been some interest about > partializing functions from the right instead (e.g. [SO post, 9k views,

[Python-ideas] Add a "partial with placeholders" function to the functools module

2019-07-27 Thread Dominik Vilsmeier
Hello, currently, regarding positional arguments, `partial` gives us the option to partialize functions from the left. There's been some interest about partializing functions from the right instead (e.g. [SO post, 9k views, 39 upvotes](https://stackoverflow.com/q/7811247/3767239)), especially

[Python-ideas] Re: for ... except, with ... except

2019-07-27 Thread Anders Hovmöller
> On 27 Jul 2019, at 10:19, Serhiy Storchaka wrote: > > 26.07.19 23:57, Guido van Rossum пише: >> These are interesting ideas. It looks like you intend the except clause of >> the for loop to *only* cover the iter() and next() calls that are implicit >> in the for loop. You're right that

[Python-ideas] Re: for ... except, with ... except

2019-07-27 Thread Serhiy Storchaka
26.07.19 21:52, Bruce Leban пише: On Fri, Jul 26, 2019 at 11:27 AM Serhiy Storchaka > wrote: So you will be able to add errors handling like in:      with connect() as stream:          for data in stream:              try:                  

[Python-ideas] Re: Skip modules by default in star-import

2019-07-27 Thread Serhiy Storchaka
26.07.19 23:53, Guido van Rossum пише: Serhiy proposed a relatively minor change to the behavior of `import *` in the absence of __all__. This sounds like an idea we could try though we should have a look at the implications for various well-known packages. It is also a relatively minor

[Python-ideas] Re: for ... except, with ... except

2019-07-27 Thread Serhiy Storchaka
26.07.19 23:57, Guido van Rossum пише: These are interesting ideas. It looks like you intend the except clause of the for loop to *only* cover the iter() and next() calls that are implicit in the for loop. You're right that it's awkward to catch exceptions there. Right. If you want to catch

[Python-ideas] Re: for ... except, with ... except

2019-07-27 Thread Serhiy Storchaka
26.07.19 23:46, MRAB пише: On 2019-07-26 19:26, Serhiy Storchaka wrote: [snip] I propose to add "except" clause to "for" and "with" statement to catch exceptions in the code that can't be wrapped with "try ... except".   for VAR in EXPR:   BLOCK   except EXC:   HANDLER

[Python-ideas] Re: Skip modules by default in star-import

2019-07-27 Thread Anders Hovmöller
> On 26 Jul 2019, at 22:53, Guido van Rossum wrote: > > Serhiy proposed a relatively minor change to the behavior of `import *` in > the absence of __all__. This sounds like an idea we could try though we > should have a look at the implications for various well-known packages. It is >