On Sun, Jan 31, 2016 at 9:14 PM, Steven D'Aprano <st...@pearwood.info> wrote:
>> Imagine taking a large and complex JSON blob
>> and loading it into a Python structure with nested lists and dicts -
>> it wouldn't violate software design principles to call up
>> info["records"][3]["name"], even though that's three indirections in a
>> row. Parsing HTML is even worse, as there's generally going to be
>> numerous levels of structure that have no semantic meaning (they're
>> there for layout) - so instead of three levels, you might easily have
>> a dozen.
>
> This might not be a Law of Demeter violation, but it's certain a violation
> of "Flat Is Better Than Nested".

Oh, absolutely! But "Flat is better than nested" is a principle of
design, and when you're parsing someone else's data structure, you
follow their design, not yours. This isn't the best of designs, but
it's what works with the file he has.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to