Re:PEP 505: Bringing None-Aware Operators to Python
by singularity2001 on Monday August 13, 2018 @03:26AM
(#17748546)
for nested loop you can do
[ Parent
| on HN ]
Re:PEP 505: Bringing None-Aware Operators to Python
by Doxin on Monday August 13, 2018 @08:10AM
(#17749444)
That's generally considered unpythonic though. A more pythonic way to write that is
for child in node.children if node.children else []:
for attrib in child.attributes if child.attributes else []:
...
Which, granted, is a lot more verbose and probably not any more readable but at least it's not abusing the or operator.