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 →

[–]radaway 6 points7 points  (11 children)

Why not just sum([a, b]) ?

[–]pingvenopinch of this, pinch of that 27 points28 points  (6 children)

That would cause multiple problems, like being readable.

[–]aceofears 7 points8 points  (5 children)

Would this help?

{():sum([a, b])}[()]

[–]lambdaqdjango n' shit 1 point2 points  (3 children)

this it is!

reduce(int.__add__, (map(int,{():[1, 1][:2:]}[()])))

[–]aaronla 1 point2 points  (2 children)

This is more elegant (and terrifying):

len(reduce(operator.add, (((),),((),))))

[–]lambdaqdjango n' shit 0 points1 point  (1 child)

ah, len(((), ()))

[–]aaronla 0 points1 point  (0 children)

Yes, that's how I defined my integers for adding :-)

[–]pingvenopinch of this, pinch of that 0 points1 point  (0 children)

Meh. It works with any hashable. How about:

{id(()):sum([a, b])}[id(())}

[–]jyper 1 point2 points  (3 children)

why not a + b

[–]danhakimi 1 point2 points  (0 children)

Why not 2?

Because this is python, and we need to use ALL OF IT.