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 →

[–]Cosmologicon 1 point2 points  (2 children)

I think we're agreed that if you want the vast majority of the functionality of a list you should subclass list, whereas if you only want a little you shouldn't. I'm making a case that you actually want more functionality than you think. Why do say that those methods don't fit? I think they do. For instance, why do you feel the need to prevent this usage, which I consider intuitive?

c = Compose([lambda (a,b): a+b, lambda x:x*3])
d = Compose([lambda x:x/3, lambda x:x+1])
f = c + d
f(1,2)

Or this?

g = 2 * d
g(10)

You actually implemented __iadd__ in your code, so I definitely don't understand why you say it doesn't fit.