5 ms·
Oddly, trying to occasionally place on the Advent of Code global leaderboard was the thing that got me most fluent in Python as its own language. Before that,
by a_e_k 2y ago
Oddly, trying to occasionally place on the Advent of Code global leaderboard was the thing that got me most fluent in Python as its own language.
Before that, I tended to write Python in a much more imperative style, since C++ is my main language; think for loops and appending to lists. Thanks to AoC, I'm now addicted to comprehensions for transforming and filtering, know the standard library cold, and write much more concise, Pythonic code.
- dbcurtis 2y agoHa ha, yeah, for sure. It is easy to tell the Python code coming from an experienced C programmer. The thing about Python is, you can just give C a semi-colon-ectomy and it pretty much works. But it isn't Python... it took me a while to get completely pickled in the Python way of doing things. Ramalho's book did more than anything to put my brain into Python mode.
- ddejohn 2y agoPython's standard library is phenomenal.
- sgarland 2y agoAnd vast. IME, people often underestimate what it can do. For example, if you need to store IP addresses in a DB, you can use the stdlib library ipaddress to validate them, then store them as an INT, casting it back to dotted-quad with Python if needed. Also, of course, Postgres has a native inet type, which performs validation and other operations, storing a v4 in 7 bytes – not quite as good as 4 bytes for an INT, but much better than the maximum 16 bytes to store a dotted-quad as a VARCHAR. But if you’ve got MySQL (or anything else without a native type), this is a solid way to save space – and more importantly, memory – that can add up over hundreds of millions of rows (session information for a large SaaS product, for example).
- emmelaich 2y agoI did my first ever AoC last year and I'm old. It was fun. Didn't get very far though. First thing that mucked me up was forgetting negative indices in Python arrays are valid. I'm an admin/SRE and don't spend enough time programming, in too many languages. C++, C, Perl, Ruby, Python, Awk, etc.