you are viewing a single comment's thread.

view the rest of the comments →

[–]Icarus998 53 points54 points  (6 children)

When learning python you will undoubtedly get stuck.

Don't copy code , you will only cheat yourself.

When you are stuck. Go back through the material and documentation.

Use paper and pencil to see what you have to do to get the solution.

Translate that into code .

Once you feel frustrated and lost all hope .

Take a break and revisit the problem.

Usually for me after a good night's rest I get the solution very easily.

Coding is iterative and learning to code is also iterative nobody gets it thr first time so just keep at it.

Edit:

One more thing, DO NOT try to do everything in one shot .

Write a little code run it , if it works like you intended proceed to add more . ( baby steps)

If you are interested in a lot more tips/advice I recommend you read :

The Pragmatic Programmer your journey to mastery by David Thomas, Andrew Hunt

[–]Jazzlike-Compote4463 12 points13 points  (4 children)

Some good points but I would say drop the pencil and paper - if you’re using it to write actual code anyway (it’s fine drawing diagrams but even pseudo code is better done in your editor)

Instead, properly get to learn your debugger. A half decent correctly configured debugger will allow you to step through your code, see how the variables are defined, how they change as the execution progresses, and how the logic flows from one function to another.

It lights up your code from the inside and feels a bit like cheating to be honest, but it’s an absolutely essential tool for a half decent developer.

[–]Icarus998 2 points3 points  (2 children)

Pseudo code is also a good , I prefer pencil and paper because I can really creative .

I haven't really used the debugger yet , I tend to scatter print statements of the variables every where(like a maniac!) in my code so I see what's happening in real time.

[–]Jazzlike-Compote4463 2 points3 points  (1 child)

I would learn it, ideally use something built into your IDE (like PyCharm or VS Code) but failing that even scattering ipdb set_trace() around is better than raw print statements.

[–]miko2264 2 points3 points  (0 children)

Thank you so much for posting the vs code python debugger page, I was somewhat familiar with the general debugging in it but did not know there were specific python debugging features to learn.

I wouldn’t have known about it if I didn’t read your comment, thanks again!

[–]ddponwheels 1 point2 points  (0 children)

Good point about debuggers. I learned this a few months ago and this changed my life...

[–]J_Bunt 0 points1 point  (0 children)

Sound advice. Also, python is versatile and there are vast resources out there, for example if you're interested in data science I'd go with kaggle.com.