Example of nasty assignment using __ setitem __:
self.outer_scopes[self.children.item(i).getNodeName()][self.children.item(i).item(j).getNodeName()] = self.children.item(i).item(j).getTextContent()
Is it possible to do something like this?
self.outer_scopes[self.children.item(i).getNodeName()][self.children.item(i).item(j).getNodeName()]
=
self.children.item(i).item(j).getTextContent()
I mean, to split the assignment, not the strings after it with \ or whatever.
You could use the backslash:
self.outer_scopes[self.children.item(i).getNodeName()][self.children.item(i).item(j).getNodeName()] \
= \
self.children.item(i).item(j).getTextContent()
But that's pretty poor style. In this case, I'd use intermediate variables to make the assignment easier to read, if possible.
Use variables to shorten your expression. Would find better names, if I know more context:
item_i = self.children.item(i)
item_j = item_i.item(j)
outer_scope = self.outer_scopes[item_i.getNodeName()]
outer_scope[item_j.getNodeName()] = item_j.getTextContent()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With