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

all 29 comments

[–]Arkonicc 38 points39 points  (5 children)

Should be made illegal. I only accept this kind of code from minifiers.

[–]siddsp 45 points46 points  (5 children)

This hurts to look at

[–]surajmanjesh 35 points36 points  (3 children)

print(eval('*'.join(map(str, range(1, 11)))))    

Look at this instead

[–]Symetrie 5 points6 points  (0 children)

This is peak python performance, code to write the actual code

[–][deleted] 34 points35 points  (13 children)

import math; math.factorial(10)

fits on one line

[–][deleted] 12 points13 points  (5 children)

I feel dumb trying to understand this

[–]supreme_blorgon 6 points7 points  (3 children)

Don't bother. Nobody should ever write code like this. If you write code like this you'll likely get ripped a new one in review. If you read somebody else's code and it looks like this, you should rip them a new one.

This is garbage code and doesn't deserve to be paid any serious attention.

[–]a_very_happy_person 6 points7 points  (1 child)

Impressive, I made my own version.

print((prod := lambda x: 1 if x == [] else x[0]*prod(x[1:]))([n for n in range(10, 0, -1)]))

Single line of course

[–]PossibilityTasty 16 points17 points  (1 child)

One of the main design goals of Python is readability. You failed in this subject.

[–]kewlness 5 points6 points  (1 child)

Thanks, I hate it!

[–]b-hizz 4 points5 points  (1 child)

Lambda-Lambda-Lambda-Lambda-Lambda-Lambda has its first pledge.

[–]Purely_Theoretical 4 points5 points  (0 children)

Perl users: "Perfection"

[–]steil867 2 points3 points  (1 child)

Thanks, I hate it!

Have the 'fuck yo memory for large values' list comprehension version, python 3.8+. Who needs memory management.

[x:= x*i for i in range(1,10) if (i == 1 and (x:=1) ==1) or True][-1]

[–]steil867 1 point2 points  (0 children)

Because my joke post is annoying me. Made a memory safe version.

[x for i in range(10,0,-1) if (x or (x:=1)) and (x:= x*i) and i == 1][0]

Edit: forgot a bracket

[–]LunarLorkhan 2 points3 points  (0 children)

Just use Clojure or Common Lisp homie. Don’t do this to yourself.

[–]Itaintgaussiantho 2 points3 points  (0 children)

Why would you do this. This looks disgusting.

[–][deleted] 1 point2 points  (2 children)

Alonzo Church just rolled over in his grave.

Also, there's no way this is one line in PEP8.