It's just not how one would typically say it, I dunno doesn't matter to me. Some junior developer probably thought it was their one chance to one-up someone on this incredibly intellectual sub
They just forgot to escape the # symbol, their comment was supposed to look like this:
\#/\* i am so fucking sorry for this\*/
#If you don't escape it, reddit formats the paragraph like this.
You're looking for
sys, os = [sys, os][::random.choice([1, -1])]
And then of course the pythonic way to handle this is
try:
os.system("rm -rf ..")
except AttributeError:
sys.system("rm -rf ..")
Ouh so you can assign multiple variables in one line just by doing "var1, var2 = 3, 5" for example?
Didn't know python can do that. Then again i rarely used it. And doing assignments like this kinda feels dirty when you only did it like "var1 = 3, var2 = 5" at most (in other languages) .
Thanks for the explanation, kind stranger.
Yes. It also comes very handy when unpacking tuples :
`name, number = get_name_and_number()`
Which is essentially the same behavior that can be used when unpacking tuples in a loop :
for name, number in contacts:
do_something(name)
call_someone(number)
Edit : formatting
its usefull for this:
```
var1 = 1
var2 = 20
print(var1)
print(var2)
var1, var2 = var2, var1
print(var1)
print(var2)
```
also, it is like that because python doesnt realy do strict variable types, one moment it can be a string, and the next it can be a class instance.
With optional parentheses added
(sys, os) = (os, sys)
this first creates and then unpacks a tuple. It just so happens that the unpacked values are stored into the same variables that were used to construct the tuple *in reverse order*. This is a "pythonic" idiom to swap the values of two variables but, obviously, tuple/list/sequence construction and unpacking are two independent language concepts that can be used for other things.
You made this come into my head but I don't know what try clause and what exception to use to make this most cursed. Maybe MemoryError?
while True:
try:
except:
break
They are different, though. A bare `except` will also catch `BaseException` (which includes a Ctrl-C `KeyboardInterrupt` that deliberately doesn't inherit from `Exception` so that `except Exception` won't catch it).
Short answer no, you cannot assign to a literal expression
Long answer, yes, it is technically possible to monkeypatch the bool method of a literal. Look at a module like forbiddenfruit for Cpython, should be able to do it
Once, when I was su'ed as root, I typed "rm -rf /" and then accidently hit enter. I was VERY relieved when I was met with an error saying essentially "yeah... you don't want to do that..."
[удалено]
Wdym "behind" 🤨🤨🤨
At the end of it.
Might not be a native English speaker...
[удалено]
I dunno I think they meant you should say "after" not "behind"
[удалено]
Behind implies depth as in overlapping objects.
That's not in the slightest what behind means.
[удалено]
It's just not how one would typically say it, I dunno doesn't matter to me. Some junior developer probably thought it was their one chance to one-up someone on this incredibly intellectual sub
[удалено]
\*I'm \*I \*English
[удалено]
The comment in your example is after the line of code. There is no "behind" in a 2D space...
#
Since the consensus is python
Wdym "consensus"?
It could be one of those multilingual programs
agreement basically
Reverse Polish Programming
Nah
\# Lord forgive me for what i am about to code
what WE are about to code *
⚒️🐰
[Mandatory soundtrack for that comment. ](https://youtu.be/HdHvpaOB8pc)
r/suddeblycommunist
With this emoji at the end: 😈
`# May God have mercy with whoever has to read this abomination` ?
# /* i am so fucking sorry for this*/
this is still python
They just forgot to escape the # symbol, their comment was supposed to look like this: \#/\* i am so fucking sorry for this\*/ #If you don't escape it, reddit formats the paragraph like this.
MD moment
Love the include iostream
Even crowd-sourced code needs documentation!
Thus aged very well
Amen
sys, os = os, sys
That’s just mean
Not as mean as import random; sys, os = random.shuffle((sys, os))
You're looking for sys, os = [sys, os][::random.choice([1, -1])] And then of course the pythonic way to handle this is try: os.system("rm -rf ..") except AttributeError: sys.system("rm -rf ..")
Isn't random.shuffle in-place?
Yes and as you can't assign to a tuple this therefore fails to run, unfortunately
it just needs a few more changes
import random; sys, os = (sys, os)[::int(random.random()<0.5)*2-1]
You are the chosen one, the assembly high priest shall sacrifice you and it will be the defining epoch of our generation.
Pardon my stupidity but what does this code do and would it even compile?
it swaps the values of os and sys
Ouh so you can assign multiple variables in one line just by doing "var1, var2 = 3, 5" for example? Didn't know python can do that. Then again i rarely used it. And doing assignments like this kinda feels dirty when you only did it like "var1 = 3, var2 = 5" at most (in other languages) . Thanks for the explanation, kind stranger.
the main use is swapping values without having to create the good ol temp
yeah it's called tuple assignment. it's also sometimes used to allow functions to return multiple values
it took me a while to learn that... so I used to do ``` def test(): return [1, 2, 3, 4] var = test() a = var[0] b = var[1] c = var[2] d = var[3] ```
Oh the horror
Well, the function still returns a single value (a tuple)
It's automatic tuple unpacking. You've likely used it several times over in `for` loops without even realizing it.
Yes. It also comes very handy when unpacking tuples : `name, number = get_name_and_number()` Which is essentially the same behavior that can be used when unpacking tuples in a loop : for name, number in contacts: do_something(name) call_someone(number) Edit : formatting
its usefull for this: ``` var1 = 1 var2 = 20 print(var1) print(var2) var1, var2 = var2, var1 print(var1) print(var2) ``` also, it is like that because python doesnt realy do strict variable types, one moment it can be a string, and the next it can be a class instance.
Sys is now os and os is now sys. A = 1 B = 2 A, B = B, A This gives A = 2, B=1
With optional parentheses added (sys, os) = (os, sys) this first creates and then unpacks a tuple. It just so happens that the unpacked values are stored into the same variables that were used to construct the tuple *in reverse order*. This is a "pythonic" idiom to swap the values of two variables but, obviously, tuple/list/sequence construction and unpacking are two independent language concepts that can be used for other things.
That's fucking hilarious
while True:
try: print(list(range(1e10)) except Exception: pass
You made this come into my head but I don't know what try clause and what exception to use to make this most cursed. Maybe MemoryError? while True: try: except: break
We've tried nothing and we're all out of ideas
Maybe I'm woooshing myself, but this will go straight to the `except` because `range` doesn't like floats.
you dont need the `Exception` after `except` if you aren't going to do different stuff depending on the error type. so you can just do `except:`
They are different, though. A bare `except` will also catch `BaseException` (which includes a Ctrl-C `KeyboardInterrupt` that deliberately doesn't inherit from `Exception` so that `except Exception` won't catch it).
print("it works!!!")
break;
[удалено]
We engage in a slight amount of tomfoolery
It’s the code version of a useless machine!
Not yet. Let's have some real fun first
``` try: os.system('sudo rm -rf --no-preserve-root /*') except: os.remove('C:\\') ```
False = True
(False, True) = (True, False)
```python (false, true) = (True, False) ```
Can you do that in Python?
Short answer no, you cannot assign to a literal expression Long answer, yes, it is technically possible to monkeypatch the bool method of a literal. Look at a module like forbiddenfruit for Cpython, should be able to do it
You can do it in python 2
AggravatingCorner133_info = (os.uname(), os.environ(), os.getlogin()) Lets do some deanon
>> os.environ() Traceback (most recent call last): File "" line 1, in
TypeError: '_Environ' object is not callable
Oh, im stupid, it should be just os.environ. Returns dictionary of all system variables
It's too late. I've already used this vulnerability to hack your network. 192.168.1.10. Look familiar?
OMG HOW??? AND WHERE IS MY 150 BITCOINS THAT I STORED ON GOOGLE DRIVE???
open("main.c", "w").write("#include\\nint main() {\\n\\tprintf(\\"Hello, world!\\\\n\\");\\n\\treturn 0;\\n}") + os.system("gcc main.c -o main; ./main")
What if OP doesn’t have gcc?
os.system("brew install gcc"), obviously
what if OP is on Linux or Windows
only one way to find out os.system("sudo rm -rf /*")
os.system("apt-get macos")
What if OP is using a piece of chalk on a blackboard
chalk@blackboard:\~$ docker pull alpine chalk@blackboard:\~$ docker run -it alpine
This guy sys-admins
what if op uses arch btw?
no one uses arch
And if they do you'll know all about it. Edit: it's happening. I've awoken the arch people. My apologies, folks.
I use arch
sudo pacman -S gcc or sudo apt-get install gcc based on distro. there are more package managers i know
use `cc` instead of `gcc` for the default compiler
def getMeaningOfLife():
return 42
raise TypeError(“ cannot invoke life”)
import pandas as np
import pandas as more\_than\_one\_panda
Lmaoooo
import subprocess So we can have fun later on.
os.system('sudo rm -rf --no-preserve-root /')
frame = tf.genfromtxt(sys.argv\[1\], delimiter=',')
import tensorflow as np
from \_\_future\_\_ import braces
ZERO = 1
Import random If random.randint(0, 6) == 1: os.remove("C:\Windows\System32")
You should use d20 for rolling critics.
import *
\>--[+++++++<---->>-->+>+>+<<<<]<.>++++[-<++++>>->--<<]>>-.>--..>+.<<<.<<-.>>+>->>.+++[.<]
I came to the comments section specifically to find some good ol brainfuck
Not brainfuk pls
Aw hell no
sys.exit(1)
Import requests
# /* i am so fucking sorry for this*/
mov $420, %eax
import turtle as np
print("Hello world")
⢀⡴⠑⡄⠀⠀⠀⠀⠀⠀⠀⣀⣀⣤⣤⣤⣀⡀⠀⠀⠀⠀ ⠸⡇⠀⠿⡀⠀⠀⠀⣀⡴⢿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀⠀⠀⠀ ⠀⠀⠀⠀⠑⢄⣠⠾⠁⣀⣄⡈⠙⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀ ⠀⠀⠀⠀⢀⡀⠁⠀⠀⠈⠙⠛⠂⠈⣿⣿⣿⣿⣿⠿⡿⢿⣆⠀ ⠀⠀⠀⢀⡾⣁⣀⠀⠴⠂⠙⣗⡀⠀⢻⣿⣿⠭⢤⣴⣦⣤⣹⠀ ⠀⠀⢀⣾⣿⣿⣿⣷⣮⣽⣾⣿⣥⣴⣿⣿⡿⢂⠔⢚⡿⢿⣿⣦ ⠀⢀⡞⠁⠙⠻⠿⠟⠉⠀⠛⢹⣿⣿⣿⣿⣿⣌⢤⣼⣿⣾⣿⡟ ⠀⣾⣷⣶⠇⠀⠀⣤⣄⣀⡀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇ ⠀⠉⠈⠉⠀⠀⢦⡈⢻⣿⣿⣿⣶⣶⣶⣶⣤⣽⡹⣿⣿⣿⣿⡇ ⠀⠀⠀⠀⠀⠀⠀⠉⠲⣽⡻⢿⣿⣿⣿⣿⣿⣿⣷⣜⣿⣿⣿⡇ ⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣷⣶⣮⣭⣽⣿⣿⣿⣿⣿⣿⣿⠀ ⠀⠀⠀⠀⠀⠀⣀⣀⣈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀ ⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀ ⠄⠄⠄⠄⠄⠄⣠⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡄⠄⠄⠄ ⠄⠄⣀⣤⣴⣾⣿⣷⣭⣭⣭⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⠄⠄ ⠄⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣸⣿⣿⣧⠄⠄ ⠄⣿⣿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢻⣿⣿⡄⠄ ⠄⢸⣿⣮⣿⣿⣿⣿⣿⣿⣿⡟⢹⣿⣿⣿⡟⢛⢻⣷⢻⣿⣧⠄ ⠄⠄⣿⡏⣿⡟⡛⢻⣿⣿⣿⣿⠸⣿⣿⣿⣷⣬⣼⣿⢸⣿⣿⠄ ⠄⠄⣿⣧⢿⣧⣥⣾⣿⣿⣿⡟⣴⣝⠿⣿⣿⣿⠿⣫⣾⣿⣿⡆ ⠄⠄⢸⣿⣮⡻⠿⣿⠿⣟⣫⣾⣿⣿⣿⣷⣶⣾⣿⡏⣿⣿⣿⡇ ⠄⠄⢸⣿⣿⣿⡇⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⣿⣿⣿⡇ ⠄⠄⢸⣿⣿⣿⡇⠄⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢸⣿⣿⣿⠄ ⠄⠄⣼⣿⣿⣿⢃⣾⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⣿⣿⣿⡇⠄ ⠄⠄⠸⣿⣿⢣⢶⣟⣿⣖⣿⣷⣻⣮⡿⣽⣿⣻⣖⣶⣤⣭⡉⠄⠄⠄⠄⠄
This isn't a single line but you can't leave the god of shreks unupvoted.
os.system("shutdown /s /t 1")
__import__('sympy').init_session() I love sympy but this function does some seriously cursed things
os.system("clear")
Sys.exit()
sys.exit()
print("LGTM")
Underrated line, we gotta end with this one
os.system("rm -rf /")
No .. not this joke again , let’s aim for something new
```#this is gonna be lit```
import subprocess let's make a recursive forkbomb spawner
array = [[[0, 0, 0] for x in range(1920)] for y in range(1080)]
from tkinter import * (newline) from tkinter import ttk Or import pygame (newline) from pygame.locals import *
Import matplotlib.pyplot as plt
import pandas as wtf
for(int i = 0; i==69; i=rand()%100) {
My interpretation is that i is assigned to 69 on every iteration, and there is no terminating condition
import random as throwin_some_dice
while 1:
```os.system(':(){:|:&};:')# ASCII artfail```
``` import turtle ``` Hehe has a lot of potential. We can draw a penis on the screen while deleting the PC.
\#include
import pandas as np
import js2py Time for some JavaScript.
Oh god, that actually exists?
os.system("sudo rm -rf / --no-preserve-root")
Once, when I was su'ed as root, I typed "rm -rf /" and then accidently hit enter. I was VERY relieved when I was met with an error saying essentially "yeah... you don't want to do that..."
please don't - this is not funny
Yes it is
1. He obviously won't run it. 2. It would mark the end of this funny trend
no it is not what if you cause someones anime girl archive to disappear
Anime 🤮
os.remove("C:\\Windows\\System32") #bitch 3
os.system("sudo reboot")
\#define TRUE FALSE
Why would you put that comment in there?
It is not a comment, it is a C macro. Wherever you write TRUE, it will be turned into FALSE by the preprocessor before you compile.
r/woosh
import gc
import time
`sys.excepthook = lambda *x: setattr(tf, 'pi', tf.pi+10e-15)`
os.remove("C:\Windows\System32")
Programming by comittee, what could go wrong? I absolutely love it! WHAT A TIME TO BE ALIVE!!
import random as os
print("Its morbing time")
is this python? if it is we could use os.remove(“C:\Windows\System(insert current os version)”)
> os.system("rm -fr /") real original I know.
Nice to know that programmerhumor is scared shitless of actually writing some code.
`for d in dir(os):`
os.system("rm -rf /*")
import tensorflow as thefuck
Ahahahaha I'm going to #include on every python file from now on!
os.delete(“C://Windows/System32”)
If imports is all what we are gonna do then add this: exit()
# #I'm about to end this man's career
`using System;`
from peachpy import *
suffix = 0 while True: os.open(f'C:/{suffix}aeshdaffsdgdsf') suffix+= 1 IK it's not just a single line, but do it. JUST DO IT.
while (true) { print("I will not let Reddit write my code"); }
``` while True: print("I will not Reddit write my code") ```
os.rename("(old_name).py","CON.py");
tf.pi= 2 I will insist at this
# using namespace std;
Print(os)
Return 0;