On Mon, Nov 23, 2020, 2:58 PM Ethan Furman

>  >>          if isinstance(node, StringNode):
>  >>              return node.value
>  >>          elif isinstance(node, NumberNode):
>  >>              return float(node.value)
>  >>          elif isinstance(node, ListNode):
>  >>              return [process_node(child_node) for child_node in
> node.children]
>  >>          elif isinstance(node, DictNode):
>  >>              return {key: process_node(child_node) for key, child_node
> in node.children}
>  >>          else:
>  >>              raise Exception('Unexpected node')
>  >
>  > You don't need the "else".
>
> Without the "else" errors will pass silently.
>

Not in the particular example. It can just be a bunch of ifs, each of which
returns something. The last line of the function can be raise.

Obviously, epic and else are very important in general. I think I wouldn't
use any for that particular code though.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/DIOGB53TRPJ3A2AN4AQIHU4WLDR5776U/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to