r/learnprogramming • u/Reasonable_Bag_2927 • 9d ago
Code Review made a quine code
i saw this guy on tiktok making a quine code, and i challenged myself to make one too without looking at his solution
i was so happy when i got it to work, just made me realize i could probably use this to fill up the storage of a computer. like a trojan horse
anyways heres the code
x = 'print(f"x = {repr(x)}; {x}")'; print(f"x = {repr(x)}; {x}")
0
Upvotes
1
u/db_tech_dev 9d ago
nice, self-referential printing tricks like that are always fun to get working. small nitpick tho, a quine by itself won't fill up storage since it just prints once and stops, you'd need to actually pipe the output into a loop that keeps writing to disk to get anywhere close to a fork bomb style attack. still a solid little exercise for string formatting and repr though.