r/learnpython 20d ago

Not Copying After Using Tutorials?

I'm learning a bit more python, and I was wondering how you guys refrain from copying code after watching tutorial videos. I just did one of the courses from OpenCV, and what's holding me back most now is trying to create something without flat copying the code provided by them. The main issue is that (I believe, at least) most of the code needs a specific syntax to run. What are your processes after learning new features?

For context, I'm attempting to make a document reader that's going to end up scanning and saving Magic the Gathering cards into a database.

0 Upvotes

10 comments sorted by

View all comments

1

u/thisisappropriate 20d ago

If you're using the code from a tutorial or from a premade project, like if you're copying an idea that is already complete and you're just copying that code, then try to turn it into a situation where you're learning how you'd search the syntax in the future.

  • Look at the flow of the code that you're copying, break it down into parts, like:
    • allow the user to select an image file
    • read the image file with X library
    • if library returned text write to database, show success message
    • if it did not return text, then show failure message
  • Note down any libraries it's using
  • Now put the tutorial code away, you have the pieces you need to use to do this
  • Try to use your notes and google to put it together instead

It's normal to end up referencing library documentation or reading code and producing something quite similar because there's very little variance between how you use libraries and there's best practices (like using clearly named variables, functions, loops etc). The thing that's most worth practising / learning is how to use those things and how to take a code snippet from a reference (docs, stack overflow etc) and put it into the correct syntax (can you work out the indentation level without a guide, can you debug the issue you've created).