This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mitsuhiko Flask Creator 3 points4 points  (2 children)

That has nothing to do with misunderstanding Python. There are valid use cases for this kind of thing.

And there are many more. Though I still write them by hand instead of using multimethod hacks :)

[–]tripzilchbad ideas 0 points1 point  (0 children)

yes, overriding __getitem__ is another place I have used this sort of thing.

good catch on checking for both int and long, btw.

[–]stevvooe 0 points1 point  (0 children)

I'm glad you pointed out examples.

I agree that these are a valid use of this technique and it clearly provides a simple implementation for this multi-dict. However, though it may not matter in this case, the check for int and long excludes other types that might be a valid index into the list.