AlSweigart
Highest Rated Comments
AlSweigart82 karma
This is pretty common. It's easy to learn the syntax to a programming language and the basic concepts, but then you feel like you don't know how to begin creating an actual program. Really, copying code that you've seen is he best way to get experience. I wrote The Big Book of Small Python Projects to provide tons of examples of small running programs. People say you should read the source code of open source projects, but those projects could be under-documented or use who knows what coding techniques or idioms, and that can be frustrating to a beginner. At the same time, I wanted something that was more than just code snippets; I wanted examples that were complete programs that you could run.
There's a thing called tutorial hell or the tutorial desert, where you've done Hello, World tutorials but are still a beginner and aren't ready to write your programs yet. So you start looking up other tutorials, only to find more Hello, World stuff that you already know. It's pretty hard to find learning materials for the intermediate level. So I wrote Big Book and also Beyond the Basic Stuff with Python to try to address readers at that level.
But basically, yes, it is totally normal to constantly be looking up stuff on Stack Overflow and copying other people's code. This is how you build experience.
AlSweigart59 karma
The problem of recursion is that it could be difficult to understand and difficult to debug. If your recursive code doesn't do any backtracking, it's most likely much easier to just use a loop instead. By "backtracking", I mean that your code does stuff after the recursive function call. If the last thing in your recursive function is returning the results of the recursive function call, you aren't doing any backtracking and don't need recursion.
Generally, if you have the question, "wouldn't it be easier to code this using a loop?" the answer is 99.9% of time, "Yes."
AlSweigart171 karma
This is the official recursion joke thread. Please keep recursion jokes under this thread.
View HistoryShare Link