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)

--
Greg
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@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/AERIZI4MRPFBJ62YAOIWO4OSXLDSMTRK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to