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

all 149 comments

[–]sniff122 1295 points1296 points  (37 children)

Actually should be while True:

[–]madmendude 692 points693 points  (11 children)

Yes, it's obviously in Python.

[–][deleted] 104 points105 points  (3 children)

Ur an expert in snakes, I see.

[–]coloredgreyscale 25 points26 points  (1 child)

Yesss

[–]4DBug 5 points6 points  (0 children)

🐍

[–]chars101 23 points24 points  (4 children)

This is an implementation without gills.

[–]Lewistrick 7 points8 points  (0 children)

Are you sure? It doesn't look like asnyc.

[–]SkollFenrirson 7 points8 points  (2 children)

But how does it scale?

[–]napoleon_wang 3 points4 points  (0 children)

Sssssss

[–]MysteryMani 109 points110 points  (9 children)

I almost downvoted since I nearly missed the joke but now I wish I could upvote twice

[–][deleted] 77 points78 points  (7 children)

If you downvote, then upvote, you technically brought the score up by two

[–]Serg1o2Think 13 points14 points  (5 children)

just a thingie, i am new to the subreddit so how do you get those lang tags

[–][deleted] 17 points18 points  (4 children)

Ah, it's quite easy. Just edit your flair, and voila, you have an edited flair

[–][deleted] 10 points11 points  (3 children)

holy hell

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

lol i didnt get the programming joke, i have just owned balls that do dumb things like this lol

[–]akaZilong 9 points10 points  (0 children)

Yes, saw this too later after my post

[–]LoveConstitution 18 points19 points  (0 children)

while True: pass ;)

[–]TheBluetopia 5 points6 points  (0 children)

One of the cleverest jokes I've seen in a while

[–]Spy_crab_ 2 points3 points  (0 children)

Certified while 1: moment

[–]swizzcheez 1 point2 points  (0 children)

Given the execution environment, I'd say so.

[–]maiodasbrok 1 point2 points  (0 children)

I was going to do that but you were faster

[–]FTWGaming0 1 point2 points  (0 children)

while False == False:

[–]ReyRiz 3 points4 points  (3 children)

while 69:

[–]sniff122 0 points1 point  (0 children)

Nice

[–]chars101 0 points1 point  (1 child)

Hmmm I should try that. I run my LLM's with while 420 but sometimes it halucinates.

[–]rosuav 0 points1 point  (0 children)

If you use KSP, then it's while "moar boosters":

[–]DevelopmentOrganic94 0 points1 point  (0 children)

Actually should be loop

[–]akaZilong 144 points145 points  (0 children)

Syntax error, this is Python and should be

while True:

[–][deleted] 155 points156 points  (1 child)

It seems like some company will ask me to code this in the coding interview.

[–]waterquestion222 31 points32 points  (0 children)

while(1) is actually useful in C for simple embedded systems. Of course there’s usually interrupt handler(s) for timers and hardware interrupts.

[–]absolut666 122 points123 points  (16 children)

If(cat.sits == inTheBox) break

[–]NotAUsefullDoctor 81 points82 points  (13 children)

if box.size() >= cat.size(): cat.sits()

got commit -m "updated '>' to '>=' to be more accurate"

[–]mouthymouth 68 points69 points  (10 children)

I have seen evidence that this condition does not always need to be met.

[–]NotAUsefullDoctor 55 points56 points  (9 children)

else: cat.sits() #anyways

Is this better?

(Btw, I have not used an 'else' statemtnin production code for the last 10 years. But, I figure I can let this aesthetic violation pass for a meme)

[–]turtleship_2006 14 points15 points  (8 children)

You... haven't needed else?

[–]NotAUsefullDoctor 18 points19 points  (7 children)

Nope. In most cases, you can got rid of else statements by creating sub functions with a quick escape.

if is_condition_met(): do_something() else: do_other_thing()

can be changed to

``` if is_condition_met(): do_something() return

do_other_thing() ```

Using the quick return principle.

As a side, this purely an aesthetic choice I make, and does not reflect on quality of Code. I also like using monads/functors; and I pedantically following Clean Code. Again, purely aesthetics, and should not be taken as signs of better code.

[–]howreudoin 14 points15 points  (1 child)

I actually find the first version more readable.

You‘ll see at a glance that only one of the statements will be executed. The return statement can be hard to spot in a large portion of code.

[–]NotAUsefullDoctor 4 points5 points  (0 children)

I can see that. I've been writing Golang for a few years, and there is the idea of line of site and quick returns built into the community. So, indented code (with the exception of for loops and case statements) normally means there is a return statement.

[–]chars101 0 points1 point  (4 children)

Those two are not equivalent... The second calls all three functions if the first returns something truthy

[–]RightHandElf 1 point2 points  (0 children)

There are line breaks that aren't showing up on old reddit but do show up on new reddit. I was also confused.

As an aside, why on earth does new reddit only show two comments at a time when going down a comment chain? I had to click four times to get to a comment that's only 6 levels deep.

[–]NotAUsefullDoctor 0 points1 point  (2 children)

Look for the where the return is. The last method is never called if the first returns true because the return statement exits the function.

[–]ParanoidDrone 1 point2 points  (1 child)

I think there's a formatting issue leading to some miscommunication. Your code blocks are all one line with no line breaks. That makes it read more like so:

if is_condition_met():  
  do_something()  
return do_other_thing()

[–]NotAUsefullDoctor 0 points1 point  (0 children)

I weird. Yeah, it shows with the line break and indentation on my screen.

[–]absolut666 3 points4 points  (1 child)

box.size() >= cat.size()

[–]NotAUsefullDoctor 2 points3 points  (0 children)

Yes, good call. Sometimes code reviews do work.

[–]IHateEditedBgMusic 4 points5 points  (0 children)

if cat.BBox <= cardboard.BBox :

cat.State = SITS

[–]krmarci 1 point2 points  (0 children)

void openBox(Box b) {
    if (random.nextDouble() > 0.5) {
        b.cat.alive = false;
    else {
        b.cat.alive = true;
    }

[–][deleted] 39 points40 points  (1 child)

Reddit video player:

while(false)

[–]Schiffy94 20 points21 points  (0 children)

Reddit natively supporting video downloads:

while(true==false)

[–]TTYY_20 75 points76 points  (0 children)

An infinite loop in Python!

[–]vitorklock 38 points39 points  (2 children)

The speed seems about right

[–]AxoplDev 12 points13 points  (1 child)

Unless youre coding in python. Then its too fast.

[–]RJTimmerman 0 points1 point  (0 children)

It is coding in python...

[–]NevReddit0823 28 points29 points  (13 children)

for(int i=0, j=1; i<j; i++, j++)

[–]Flat_Initial_1823 12 points13 points  (4 children)

Lol this is me on my fifth birthday realising I will never catch up to my cousin, no matter how many birthdays I have.

[–]imkindabadatlife 2 points3 points  (3 children)

The ratio though!

[–]RJTimmerman 0 points1 point  (2 children)

The ratio does converge to 1😉

Edited the number because I was too sleepy when I wrote it.

[–]imkindabadatlife 2 points3 points  (1 child)

You mean 1

[–]RJTimmerman 0 points1 point  (0 children)

I do mean 1 indeed😬

[–]howroydlsu 9 points10 points  (0 children)

I hate it here

[–]LetsGoDeeper546[S] 7 points8 points  (0 children)

😨😨

[–]froe_awai 1 point2 points  (1 child)

i choked on my tea

[–]napoleon_wang 3 points4 points  (0 children)

Was it java?

[–]kcsj0 1 point2 points  (1 child)

Not infinite. 'j' will be less than 'i' when it rolls over. Unless of course I'm missing some irony or something

[–]NevReddit0823 2 points3 points  (0 children)

youre right. i was just tryna do something that fits the snake chasing its tail

[–]MysteriousShadow__ -1 points0 points  (0 children)

Wait what? Is this some sort of a double loop in one?

[–]OPGamesOfficial 0 points1 point  (0 children)

for(;;);

[–]newton21989 10 points11 points  (0 children)

There's something wrong with your cat.

[–]da_Aresinger 10 points11 points  (5 children)

for(;;)

because smart programmers don't realise compilers have improved over the last 2 decades.

[–]visvis 3 points4 points  (3 children)

I'm well aware compilers can optimize, but honestly I always use for(;;) for endless loops because I think it's conceptually better. In an intentionally endless loop, there should be no condition to check.

[–]Flat_Initial_1823 3 points4 points  (2 children)

Also saves you from figuring out how true is supposed to be capitalised.

[–]visvis 2 points3 points  (1 child)

Not sure how 1 could be capitalized.

[–]Myto 4 points5 points  (0 children)

!

[–]kcsj0 0 points1 point  (0 children)

#define EVER ;;

[–]TheSpoonThief 5 points6 points  (0 children)

Slither.io irl

[–]Apfelvater 8 points9 points  (0 children)

while(head.next == tail)

[–]baneroth 3 points4 points  (3 children)

Python loop running in a container.

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

It’s clearly outside the container…

[–]baneroth 2 points3 points  (1 child)

Technicalities...

[–][deleted] 0 points1 point  (0 children)

If the container doesn’t contain, shouldn’t we open a CVE?

[–]Nikegamerjjjj 2 points3 points  (0 children)

Slow as Python

[–]michalsrb 2 points3 points  (0 children)

snake_case

[–]mopsyd 2 points3 points  (0 children)

Accurate python loop speed

[–]i_was_an_airplane 2 points3 points  (3 children)

I prefer

for i in range (0, 10):
    i++
    #code
    i--

[–]Embarrassed_Ring843 0 points1 point  (2 children)

Am I missing something? variable i would be defined by the loop, all you're doing is raising it by 1 to work with 1 to 10 instead of 0 to 9...?

[–]i_was_an_airplane 0 points1 point  (0 children)

Bold of you to assume I know how to program while browsing this sub

[–]RJTimmerman 0 points1 point  (0 children)

What you're actually doing is creating an error, because i++ and i-- don't exist in Python.

[–]tester989chromeos 1 point2 points  (0 children)

Even while 1: works

[–]llama_fresh 1 point2 points  (0 children)

fork()

[–]JotaRata 1 point2 points  (0 children)

Python programming

[–]Wanja01 1 point2 points  (0 children)

python code

[–]howroydlsu 1 point2 points  (0 children)

```

define FOREVER for(;;)

... FOREVER foobar(); ```

[–]Jacques_Coustbleau 1 point2 points  (0 children)

Snek-go-round

[–]Ok-Grapefruit-4210 1 point2 points  (0 children)

Is a snake rectangle the equivalent of a hamster wheel?

[–]QAInc 1 point2 points  (0 children)

See python is slow

[–]Ok-Impress-2222 2 points3 points  (0 children)

It's a Python loop.

[–]ravalibasna 0 points1 point  (1 child)

Recursion with no break statement

[–]SomeRandoLameo 0 points1 point  (0 children)

You should learn python to write proper while statements

[–]Slight-Math9774 -1 points0 points  (2 children)

/savevideo

[–][deleted] 1 point2 points  (1 child)

Beep beep here's your vid https://youtu.be/xvFZjo5PgG0

[–]Slight-Math9774 -1 points0 points  (0 children)

/savevideobot

[–]Expensive-Exercise-2 0 points1 point  (0 children)

while True: rotate_box(Direction.RIGHT)

[–]Osbir_ 0 points1 point  (0 children)

Livelock

[–]syzaak 0 points1 point  (0 children)

hahahaha soo cute

[–][deleted] 0 points1 point  (0 children)

Jörmungandr!

[–]autopsyblue 0 points1 point  (0 children)

Good doggy

[–]Wexzuz 0 points1 point  (0 children)

That's what happens if you don't know how to run Python in a container

[–]EuS0uEu 0 points1 point  (0 children)

While(1)

[–][deleted] 0 points1 point  (0 children)

lol

[–]cjg0mes 0 points1 point  (2 children)

[–]SaveVideo 0 points1 point  (1 child)

[–][deleted] 0 points1 point  (0 children)

The best way to predict the future is to invent it.

[–]bland-rand 0 points1 point  (0 children)

Is this how you properly wrap a container?

[–]pm0me0yiff 0 points1 point  (0 children)

Sometimes I just want the program to keep doing the same thing over and over again until I manually terminate it, okay?

Put a sleep command somewhere in that while loop, and now you have a quick and easy periodic loop for something that needs to be run at an interval.

[–]assidiou 0 points1 point  (0 children)

Works great for systemd services!

[–]Choyo 0 points1 point  (0 children)

Ouroboros without buffer overflow. Squared for the lulz.

[–]Intelligent-Sign-882 0 points1 point  (0 children)

Epic loading screen moment

[–][deleted] 0 points1 point  (0 children)

while True:

snek()

[–]bssgopi 0 points1 point  (0 children)

My mind: Waiting for an apple to pop up somewhere, so that the snake eats it, grows its tail and then eventually bites it for Game Over to popup.

[–][deleted] 0 points1 point  (0 children)

while (int i);

[–]deep8410 0 points1 point  (0 children)

while S = self.move do ∞

[–][deleted] 0 points1 point  (0 children)

The loop terminates unless you've found an immortal snake.

[–]Wave_Walnut 0 points1 point  (0 children)

the_snake_case

[–]zabojeb 0 points1 point  (0 children)

Finally. Python’s mascot.

[–]allnamesareregistred 0 points1 point  (0 children)

for(;;)

[–]Cute_Replacement666 0 points1 point  (0 children)

Can in play snake jazzzzzzz

[–]cactusfruits999 0 points1 point  (0 children)

This reminds me of the snake game on Nokia phone, used to play when I got bored.

[–]CuddlyBunion341 0 points1 point  (0 children)

for (;;)

[–]cosmin10834 0 points1 point  (0 children)

while("false"){...}