Yes, that line is legal python. It would be better written as an ldict.update() statement though. I think the idea is that we should expect that lagend labels that are the same across axes objects are intended to be the same entry in the figure legend, which makes sense. However, this does confuse situations where the same label is used multiple times within an axes. At the very least, this code needs to be much better commented to explain its intentions and purpose.