r/learnpython • • Nov 27 '20

Milestone - 1,000 lines of code - TU r/learnpython!

Hi friends,

Just wanted to tell you all that I reached my first 1,000 lines of Python code (wanted to show a pic, but not allowed). I'm going through the book Python Crash Course, 2nd edition and doing all the exercises and some of the examples. Strongly recommend this resource, as so many others already have done. Also, I want to say a huge thank you to this community! I wouldn't have come this far without you <3

333 Upvotes

49 comments sorted by

View all comments

54

u/potato-sword Nov 27 '20

Congrats! Just a suggestion for the future, try not to measure your learning / success by lines of code written as there is no correlation between the two.

You may find yourself refactoring code to increase reusability which can reduce the number of lines. As well, you may be able to accomplish some tasks in just a couple lines depending on the implementation. For example, using a list comprehension instead of a for loop.

17

u/TheTruthIsOutThur Nov 27 '20

I'm not sure I'd say there's no correlation. Lines of code is a metric of time spent coding, and I definitely would say the more you practice the better you are. Even if these 1000 lines OP is mentioning are garbage, I bet OP is a lot more competent now than before they wrote them.

That said. "Time spent coding" is probably more correlated haha

5

u/soul_fly25 Nov 27 '20

I agree, I would not say there is no correlation and I 100% back the more practice the better. Coding is a skill that requires constant practice. But practice doesn't consist of purely writing code. Lines of code written is a shit metric of measurement as it doesn't account for any real world factors.

Things like complexity of the problem being solved, reading and understanding the existing code base you're going to add to or fix a bug in, design and architecture, hashing out stakeholder requirements etc.. all require significant practice. But if you're looking at how many lines of code did you write, you're ignoring the value that all these other things bring to the code you do write.

4

u/potato-sword Nov 27 '20

I agree, writing code is good, and you learn by coding.

But from my own experiences, I've found that during my learning journeys I would reach a point where I realized less is more. By this I mean, I started learning how to write more succinct code, whether it was with syntactic sugaring, reusable components, or implementing libraries. I would often look back at my past spaghetti code, and wonder why I spent hundreds of lines of code to implement something that could be done in less.

Overall, I think there are better ways to measure your learning. I believe creating a learning plan consisting of concrete and measurable goals for yourself can be one way to do this, but mileage may vary.

1

u/lolslim 🐍Telegram🤖 Nov 27 '20

honestly this is how I feel right now, I feel so accomplished on this python script, and since I coded other projects since, I went back and realized how WET I am, and trying to DRY it up now.

Hehe, word play.

2

u/ryrythe3rd Nov 27 '20

I get DRY, but what is WET?

2

u/RangerPretzel Python 3.7+ Nov 27 '20

We enjoy typing

or

Write everything twice (or thrice)

3

u/lolslim 🐍Telegram🤖 Nov 27 '20

WET = "Write Everything Twice"

1

u/ryrythe3rd Nov 27 '20

Makes sense, I always have to fight that urge

1

u/Vitaman02 Nov 28 '20

I've heard it as "We Enjoy Typing"

2

u/lolslim 🐍Telegram🤖 Nov 28 '20

ohhh, i like that one too.