r/learnpython • • Feb 20 '21

What are you having difficulty learning or are currently struggling to learn?

I'm curious what the community here has difficulty with when it comes to learning Python. Partly because I want to see if the more experienced community here (or myself) can help point you into the right direction. . . but also because I'm trying to come up with video tutorial ideas for future content and would love to hear from Python learners what would be most useful to dedicate our time on.

I'm looking forward to hearing what you guys have to say!

417 Upvotes

324 comments sorted by

View all comments

3

u/ffrkAnonymous Feb 20 '21

Mine is a subjective difficulty. I've been practicing Test Driven Development from the testing goat book. Following along in the book is not an issue. But when writing my own code from scratch, I'm not sure how granular/piecemeal to make my tests/functions. And the "don't test constants" I understand, but don't quite know how to put into practice. Like how should (or not) test helloworld.py . And eventually, I'll need to test graphics (e.g. tkinter) which does stuff but not in the beginner test units of value-in begets value-out .

3

u/MaraudingAvenger Feb 20 '21

I'm one of the weirdos that doesn't worship the goat. If you're doing a massive project, I completely understand how writing your unit tests first and then programming to those unit tests makes a lot of sense, to keep a team focused on the same outcome... but.... for personal projects, or projects where I don't have a huge idea of the overall shape until I'm about halfway through, it's a total motivation killer and way overcomplicates something that I'd rather get going/make real progress on.

I think the right answer is probably, "make your tests as granular as you're comfortable with," or something along those lines -- good ideas are good, until they're not.

2

u/ffrkAnonymous Feb 21 '21

For now, I'm just practicing. Paraphrasing, gotta know the rules before you break them.

As a personal anecdote, perhaps because I'm still early in my skills, and I don't know what I'm doing, because I don't know the shape, TDD has been helpful for me in making progress in Advent of Code. I write random-ish little pieces of code, and putting them together, and then expand them. TDD has helped me see patterns, that would be refactored into more generic structures, that I couldn't come up with in my head. Starting with base cases and working out to generic cases.

1

u/daroch667 Feb 21 '21

In your opinion, is the goat book useful for someone who is learning the testing part but does not use web at all?

Trying to better understand testing and mocks, but when I read the description for that book it seemed to be web dev focused (and I'm trying not to learn five languages at once...)

2

u/ffrkAnonymous Feb 21 '21

Tbh, I never passed chap 5 or 6. I just keep re-reading the first 4 because that's the core of TDD. Test, write, refactor. I think I'm getting the hang of it. I don't have any productivity metrics but I feel much more confident in my code. (don't forget I'm a beginner - middle coder)

It's free online, so you can read the parts that interestyou .

Obeythetestinggoat.com

My own other personal change is that because I write small code, I use doctest instead of unittest.

Personally, my eureka moment is when I took the mantra "write minimal code" to heart. That allowed me to finish and have working code. True it only worked for one single specific input /use case, but it worked. Which is better than well thought out code that doesn't work. Then refactor.