[Python-ideas] Re: "except BaseException with f as result"

2020-04-08 Thread Greg Ewing
On 9/04/20 1:37 am, Soni L. wrote: On 2020-04-08 10:33 a.m., Greg Ewing wrote:     try:     first = next(iterator)     except abdl.exceptions.ValidationError as e: validation_handler(e)     except StopIteration as e: return stop_handler(e) ... I can do that today, can't I? Yep! --

[Python-ideas] Re: "except BaseException with f as result"

2020-04-08 Thread Soni L.
On 2020-04-08 10:33 a.m., Greg Ewing wrote: On 9/04/20 1:22 am, Soni L. wrote: it's hard to reason about it if your eyes just keep jumping into the except bodies because they have the same indentation and everything as the normal code. I am gonna say my proposal improves accessibility,

[Python-ideas] Re: "except BaseException with f as result"

2020-04-08 Thread Greg Ewing
On 9/04/20 1:22 am, Soni L. wrote: it's hard to reason about it if your eyes just keep jumping into the except bodies because they have the same indentation and everything as the normal code. I am gonna say my proposal improves accessibility, even if it doesn't make a difference to most ppl.

[Python-ideas] Re: "except BaseException with f as result"

2020-04-08 Thread Soni L.
On 2020-04-08 10:22 a.m., Soni L. wrote: On 2020-04-08 10:12 a.m., Joao S. O. Bueno wrote: On Tue, 7 Apr 2020 at 23:17, Greg Ewing > wrote: On 8/04/20 1:14 pm, Soni L. wrote: >      def get_property_values(self, prop): >      try:

[Python-ideas] Re: "except BaseException with f as result"

2020-04-08 Thread Soni L.
On 2020-04-08 10:12 a.m., Joao S. O. Bueno wrote: On Tue, 7 Apr 2020 at 23:17, Greg Ewing > wrote: On 8/04/20 1:14 pm, Soni L. wrote: >      def get_property_values(self, prop): >      try: >      factory =

[Python-ideas] Re: "except BaseException with f as result"

2020-04-08 Thread Joao S. O. Bueno
On Tue, 7 Apr 2020 at 23:17, Greg Ewing wrote: > On 8/04/20 1:14 pm, Soni L. wrote: > > > def get_property_values(self, prop): > > try: > > factory = self.get_supported_properties()[prop] > > except KeyError with keyerror_handler; > > iterator =

[Python-ideas] Re: "except BaseException with f as result"

2020-04-08 Thread Stephen J. Turnbull
Andrew Barnert writes: > I don’t like the idea either; but I think I like your version even less. > > It reads perfectly well, but with the wrong meaning. Even though I > know what you’re intending, I can’t make myself read that as result > getting bound to what f returns, only as result

[Python-ideas] Re: "except BaseException with f as result"

2020-04-08 Thread Andrew Barnert via Python-ideas
On Apr 7, 2020, at 22:58, Stephen J. Turnbull wrote: > > BTW, although obviously I don't like the idea much, I think > >except BaseException as result with f: > > reads better than the original suggestion: > >except BaseException with f as result: > > in the event this idea gets

[Python-ideas] Re: "except BaseException with f as result"

2020-04-07 Thread Greg Ewing
On 8/04/20 1:14 pm, Soni L. wrote:     def get_property_values(self, prop):     try:     factory = self.get_supported_properties()[prop]     except KeyError with keyerror_handler;     iterator = factory(self._obj)     try:     first = next(iterator)   

[Python-ideas] Re: "except BaseException with f as result"

2020-04-07 Thread Soni L.
On 2020-04-07 10:12 p.m., Soni L. wrote: the fact that exception handlers aren't reusable and composable is really bothering me so I would like to propose something to make them reusable and composable. for example, if I have this mess:     def get_property_values(self, prop):     try: