Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It 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.



Numpy 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.


It'd only be bad style due to the confounding and misleading variable name, not necessarily due to the operation or potential operator overloading.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: