![](https://secure.gravatar.com/avatar/3a304881dc609b0382ec45d20b7ae9c5.jpg?s=120&d=mm&r=g)
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 <greg.ewing@canterbury.ac.nz <mailto:greg.ewing@canterbury.ac.nz>> 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 = factory(self._obj) > try: > first = next(iterator) > except abdl.exceptions.ValidationError with validation_handler; > except StopIteration with stop_handler as return > return itertools.chain([first], iterator)
I don't think special syntax is warranted for this. You can write:
try: first = next(iterator) except abdl.exceptions.ValidationError as e: validation_handler(e) except StopIteration as e: return stop_handler(e)
I agree - and this is far more readable than any of the propositions so far. (Like, for an order of magnitude).
I'd wait for Soni to try to explain why this would not fit his use case, before proceeding with the bikeshedding.
have you looked at the syntax highlighting of the thing?
it sees keywords *everywhere* (which is right) it's basically unmaintainable. having the exception handlers have an exceptional syntax would set them apart from the rest of the code and make the whole thing much easier to read and maintain.
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.
(also: I'm a they. forgot to include that in the reply. sorry.)
-- Greg _______________________________________________ Python-ideas mailing list -- python-ideas@python.org <mailto:python-ideas@python.org> To unsubscribe send an email to python-ideas-leave@python.org <mailto:python-ideas-leave@python.org> https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/AERIZI... Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list --python-ideas@python.org To unsubscribe send an email topython-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived athttps://mail.python.org/archives/list/python-ideas@python.org/message/Z5QFJE... Code of Conduct:http://python.org/psf/codeofconduct/