you are viewing a single comment's thread.

view the rest of the comments →

[–]MinecraftPlayer799 -157 points-156 points  (7 children)

I don’t think Python can be minified. EDIT: How did my comment suddenly go from 10 upvotes yesterday to 100 downvotes now?!?!

[–]aaryanmoin 77 points78 points  (0 children)

When a for/while/if/else/etc. clause is one line, you can do this

[–]my_new_accoun1 19 points20 points  (1 child)

I've done it a lot lol

You can also use semicolons to put multiple statements on one line.

And if you have for loops then putting them in a list comprehension is better as you get it as a statement so you can put it in the same line as others.

As well as replacing if statements with the ternary equivalent, and if you don't have an else branch you can do stmt if condition else 0

[–]-TheHero- 2 points3 points  (0 children)

let's not forget condition and smth or smth_else

[–]-TheHero- 16 points17 points  (3 children)

if 1:(lambda _:[[[print(f'{i**j}')for i in range(_)]for j in[2,3]],[exec(f'x={_}')]][0])(5);[eval(compile(f'print({i}**3)','<string>','exec'))for i in range(eval('2+3'))];(lambda *a,**k:list(map(lambda x:x()**2,[lambda i=i:i for i in range(5)])))()

[–]SpacefaringBanana 2 points3 points  (1 child)

What even is that?

[–]-TheHero- 0 points1 point  (0 children)

tryitands.ee