3 ms·
That is completely normal syntax that "always" worked with the right thing named `list`.
by filmor 6y ago
That is completely normal syntax that "always" worked with the right thing named `list`.
- dmurray 6y agoIt worked if "list" was specifically a dictionary one of whose keys was the tuple (1, 2, 3, 4), and only then because Python allows you to omit the parentheses around the tuple in most situations. Or it could work with a custom type with overridden operators through __getitem__. It's a stretch to call it "completely normal" though I believe you're correct in a strict sense: you could always construct the rest of your program such that it would contain that line and still compile. It would be extremely bad style.
- duckerude 6y agoNumpy supports that style of indexing for multidimensional arrays, so it's not that outlandish. Not something you'd use with the standard library though. I guess I wouldn't call it "completely normal" either.
- meowface 6y agoIt'd only be bad style due to the confounding and misleading variable name, not necessarily due to the operation or potential operator overloading.