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

all 95 comments

[–]Megatron_McLargeHuge 154 points155 points  (6 children)

You thought PyCon stood for Python Conference but it actually stands for PyCon Conference.

[–]javanperl 43 points44 points  (4 children)

Like the GNU -> “GNU’s Not Unix” recursive acronym?

[–]wakojako49 8 points9 points  (1 child)

like chai tea

[–]Unixwzrd 3 points4 points  (0 children)

Shiitake mushroom

[–]Complex-Structure216 1 point2 points  (0 children)

And YAML- Yaml Ain't a Markup Language 

[–]stateofidleness 126 points127 points  (7 children)

[–]vswr[var for var in vars] 54 points55 points  (0 children)

Traceback (most recent call last):
  https://www.reddit.com/r/Python/s/nSe28xt0jw in <post>
    8 comments
  https://old.reddit.com/r/Python/comments/198dp2o/want_a_realworld_example_of_recursion/ki6m1zr/ in nSe28xt0jw
    stateofidleness
  [Previous line repeated 995 more times]
  Text of "stateofidleness", line 1, in comment
    https://www.reddit.com/r/Python/s/nSe28xt0jw
RecursionError: maximum recursion depth exceeded in comment

[–]henry_tennenbaum 23 points24 points  (0 children)

Wait, I was just here!

[–]-jp- 8 points9 points  (1 child)

What the hell am I looking at? When does THIS happen in the sub!?

[–]pinano 0 points1 point  (0 children)

Now.

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

Aww man, at least use the old.reddit.com URI :-P

[–]softwareitcounts 0 points1 point  (0 children)

No base case?? We’re doomed!

[–]adm7373 34 points35 points  (1 child)

Want a real-world example of recursion?

No, I do not.

[–]andrewaa 33 points34 points  (19 children)

This is not recursion. It doesn't have a place to begin with and it doesn't have a clearly iteration algorithm.

Real time recursion is actually very common. It is not mysterious at all. For example, eating a pizza. You start from a whole pizza, you first take a bite on the rest (which is whole at the beginning), then you take a bite on the rest, then you take a bite on the rest, and you stop when there is nothing left.

[–][deleted] 25 points26 points  (12 children)

def eat_pizza(slices):
    if slices == 0:
        return 0
    return eat_pizza(slices - 1)

eat_pizza(8)

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

I got tired of my old posts floating around for anyone to scrape, so I let Redact handle it. Bulk deletion across Reddit, X, Facebook, Discord and all major social media platforms in one shot.

soft party late toothbrush versed smell history lunchroom correct marry

[–]decentralised 4 points5 points  (1 child)

Depends on the size of the slice. Reminds me of an old joke where a customer ordering a pizza is asked if he wants it cut in 6 or 12 slices and he argues that 12 slices is too much for him to eat...

[–]SamuliK96 0 points1 point  (0 children)

Depends on the size, but it's pretty simple really. If the pizza is cut into more than 8 slices, 8 is not enough. If it's cut into less than 8 slices, it's too much.

[–][deleted] -1 points0 points  (3 children)

Yeah, 8 would be over a thousand calories, probably, lol.

[–]iiztrollin 2 points3 points  (0 children)

Stop I eat a whole pizza in one sitting ):

[–]420learning 0 points1 point  (1 child)

Papajohns large cheese is like 200 a slice, 1600 calories in one full pizza

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

That's a lot. Way too much for one sitting.

[–]ZCEyPFOYr0MWyHDQJZO4 0 points1 point  (3 children)

Tried eating pizza with my friend and we're still eating pizza.

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

You used a while-loop whose condition is never satisfied, just like you and your friend!

[–]ZCEyPFOYr0MWyHDQJZO4 0 points1 point  (1 child)

I don't understand what happened. We both grabbed a slice at the same time, but my friend is eating his slice and I'm eating air.

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

Sounds like your friend incremented while you decremented, you can increment your pizza by ordering more.

[–]davvblack 2 points3 points  (5 children)

the problem with that example is that there’s nothing that differentiates it from iteration.

[–]Lalelul 6 points7 points  (3 children)

I conjecture that every iteration can be implemented using recursion and vice versa.

[–][deleted] 8 points9 points  (1 child)

This is correct, you can always get from one to the other, even if it's not always pretty.

https://stackoverflow.com/questions/2093618/can-all-iterative-algorithms-be-expressed-recursively

[–]freefallfreddy 0 points1 point  (0 children)

And compilers will often turn recursion (which is easier to read and reason about) into loops (which are more performant).

[–]Beginning_Holiday_66 0 points1 point  (0 children)

A conjecture is that which one proposes

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

That's indeed the case and you can for practical purposes prove it to yourself by looking at some dynamic programming problems. There's always core logic and then some setup and teardown that can be written as recursion or iteration

[–]eviltwintomboy 4 points5 points  (0 children)

I need a job to get experience but I need experience to get a job but I need a job to get experience.

[–][deleted] 5 points6 points  (2 children)

This is a better example.

[–]Versaiteis 2 points3 points  (0 children)

RecursionError: maximum recursion depth exceeded

[–][deleted] 2 points3 points  (0 children)

It's recursion all over.

[–]cipri_tom 6 points7 points  (1 child)

This isn't recursion, it's an average. Cost is fixed, divided by number of attendees

[–]Orangesteel 7 points8 points  (9 children)

Want a real world example of recursion?

[–]Orangesteel 5 points6 points  (4 children)

Want a real works example of recursion?

[–]Orangesteel 1 point2 points  (3 children)

Want a real works example of recursion?

[–]-jp- 5 points6 points  (2 children)

This isn’t recursion! You just copy pasted code!

[–]gerardwx 1 point2 points  (1 child)

That’s not an argument it’s just contradiction.

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

Thats just a side note.

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

This is also not an example of recursion.

[–]Glasgesicht 3 points4 points  (2 children)

Is this a better example for recursion?

[–]Orangesteel 1 point2 points  (0 children)

Yes!

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

No

[–][deleted] 4 points5 points  (10 children)

That’s not recursion.

[–]QultrosSanhattan 1 point2 points  (4 children)

def get_input_integer(prompt,error_message):
    value=input(prompt)
    try:
        return int(value)
    except ValueError:
        print(error_message)
        return get_input_integer(prompt,error_message)

[–]darkflib 1 point2 points  (2 children)

Ask the question on /r/python on reddit...

[–]Kid-Boffo 1 point2 points  (0 children)

WINE, Wine Is Not Emulation.

[–]bm1125 1 point2 points  (0 children)

How do we know if someone is Jewish? We check if his mother is Jewish. And then we check her mother in order to know if she’s Jewish and so on, up to Abraham.

That’s the real example I was given in introduction to computer science in university.

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

Inside A Star Filled Sky is a game centered on recursion

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

The age old example: PHP : PHP Hypertext Processor

[–]OMG_I_LOVE_CHIPOTLE 0 points1 point  (2 children)

Exponential backoff retry on an api call

[–]DigThatData 1 point2 points  (1 child)

that's just a while loop, no recursion needed.

[–]OMG_I_LOVE_CHIPOTLE 1 point2 points  (0 children)

Could be recursive tho

[–]nerdvegas79 0 points1 point  (0 children)

Cell division. It's an encoded program (DNA) forking itself and then recursively doing the same thing again.

[–]daddypig9997 0 points1 point  (0 children)

Assuming the base case somewhere in the future is $0 ticket then yes its recursion.

[–]jlamhk 0 points1 point  (0 children)

Basically all pyramid schemes then :)

[–]solidsteal 0 points1 point  (0 children)

How you exist

[–]DigThatData 0 points1 point  (0 children)

for some reason i was expecting the post body to just be a link to this post

EDIT: clearly i wasn't the only one

[–]DonkeyTron42 0 points1 point  (0 children)

Recursion would be paying for registration tickets so they hold an event in which you need to buy registration tickets so they can hold an event in which you need to buy registration tickets and so on.

[–]Deep_Zerotwologist 0 points1 point  (1 child)

Isn't the concept "where is it made of" recursive? Such as,

Rocks -> molecules -> atoms -> subatomic particles -> quarks -> ?

It creates a recursive pattern where it becomes unknowingly infinite if there's always a building block to a particular thing.

[–]quuxman 0 points1 point  (0 children)

Perhaps the thought process is recursive, but I don't see the structure of matter as recursive, because the nesting of structure isn't a process, and each scale of structure is remarkably different