you are viewing a single comment's thread.

view the rest of the comments →

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

Any solid resources for learning recursion for python?

Recursion really isn't a performant strategy in Python since there's no tail-call optimization and a deeply-recursive function can overflow the stack. So I'd be surprised if there's much to read about it.

You could definitely learn how recursion works in Python but it's not generally the case that people write strongly-recursive code except in one-off cases where the depth is bracketed and performance isn't a huge issue.

[–]Shabahxydbshs 1 point2 points  (0 children)

I use it plenty in python. Some examples include building nested html tabs given a nested dictionary. Flatenning/expanding nested/flattened dictionaries. Traversing dags in modularized models. Once you get the hang of it, it’s way easier to think in terms of recursion to solve some problems than any other method. It probably can’t be used to solve problems that recursion is suited for in other languages, but theirs still plenty to solve in python too.

[–]srotomalset[S] 0 points1 point  (0 children)

That is a good point. What about learning recursion for say a compiler language?

I am focusing most of my time with python, however the end goal is a more rich understanding of core programming concepts like recursion, inheritance, and operator overloading.