4 ms·
I understand it exactly. Really? Containers of different types have a len method; which type of container is pets? The line you wrote doesn't tell you. And is
by pdonis 13y ago
I understand it exactly.
Really? Containers of different types have a len method; which type of container is pets? The line you wrote doesn't tell you. And is owners supposed to be a set? If so, your comparison to an empty dict will give the wrong semantics if owners is an empty set (owners != {} will return True for an empty set, not False). You would have to write
len(owners) > 0
to get the correct semantics. Which, of course, already obscures the type of owners, just as the type of pets is obscured.
In short, your suggested "improvement" over idiomatic Python still obfuscates rather than clarifying.