TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How do you become a better Python developer?

31 点作者 bloominggarden超过 2 年前
I assume that a lot of this just comes down to general SE experience but I am looking to actively learn how to write more "pythonic" code.

19 条评论

yellowapple超过 2 年前
Every good programmer was once a bad programmer. They typically evolve into good programmers by iteratively identifying what they don&#x27;t like about their own code and fixing those issues. Those fixes will often need fixes down the line, but that&#x27;s okay.<p>Your first step for that identification should be to list your priorities for the end result. Readability? Robustness? Speed? Compactness? Reusability? Extensibility? Once you know by what metrics you want your code to be &quot;good&quot;, you can start to examine where your code falls short.<p>The other key thing is to be unafraid to write bad code. It&#x27;s hard to know when or why something&#x27;s bad until you&#x27;ve held it in your hands, fiddled with it, given it a good swing. From there you can refine it by whatever metrics you&#x27;ve prioritized (per above).
评论 #34838309 未加载
hayst4ck超过 2 年前
Install linters, they will correct one class of unpythonic code.<p>Next google &quot;idiomatic python.&quot; <i>Idiom</i> is the software word for the &quot;right&quot; way to do something.<p>After linters and idioms, code will probably look pythonic. Next is overall structure, which IMHO, python is not super opinionated on.<p>What becomes more useful to understand are the different software paradigms: <i>procedural</i>, <i>functional</i>, and <i>object oriented</i>.<p>Once you understand paradigms a bit, it&#x27;s worth understanding object oriented in more detail. Misko Hevery has a lot of great things to say on that.<p>At this point, you should be able to write <i>extremely boring</i> python. Nothing is better than extremely boring code.<p>After that, watching videos, reading books, reading code, and writing code is the way.<p>Learning google&#x27;s Bazel is probably also important, since any sufficiently large python project will crumble under its own complexity without Bazel or a system like it.
Cody_C超过 2 年前
Whenever I am on a project, I try to write any tooling (code generators, utils, scripts, etc) in the tech that it uses. This forces you to broaden your horizons in the tooling. I even have a toolbox git repo that has a bunch of different tools written around this concept that I have often reused.<p>I would also recommend trying to &#x27;think&#x27; in the language. Don&#x27;t just try to push a solution into the language. Dig deep and see if there is something specific that makes the most sense to use.<p>Overall, I wouldn&#x27;t try to push away your style entirely. I don&#x27;t think you truly can. I would say the best bet is try to be a great engineer, with strong baseline principles which you then apply in the best way for each environment. Every decision is a tradeoff and many of the big schisms in tech come down to taste. Actively work to learn new ways of doing things. Work to understand other&#x27;s code longer than you think you should.
jstx1超过 2 年前
&gt; I am looking to actively learn how to write more &quot;pythonic&quot; code.<p>Effective Python is a great book which aims to teach people who already know the language how to use it well.
hbrn超过 2 年前
Raymond Hettinger talks are a good start (e.g. <a href="https:&#x2F;&#x2F;youtu.be&#x2F;wf-BqAjZb8M" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;wf-BqAjZb8M</a>)<p>Every now and then read Zen of Python and try to understand it. Tim Peters somehow managed to fit enormous amount of wisdom in it.
bilsbie超过 2 年前
I’d find some GitHub repositories of popular libraries that are known to be well written and look through their code.<p>I believe this was a good one back in my day. <a href="https:&#x2F;&#x2F;github.com&#x2F;psf&#x2F;requests">https:&#x2F;&#x2F;github.com&#x2F;psf&#x2F;requests</a>
clusmore超过 2 年前
Watch anything by Raymond Hettinger on YouTube.
ReflectedImage超过 2 年前
Go write a FastAPI based Rest service which talks to PostgreSQL via SQLAlchemy.<p>Then set up some compete workers that read in jobs from a RabbitMQ queue. Have the Rest service add jobs to the queue and get back the results.<p>Also you can just read the official Python tutorial for learning stuff like with contextmanager.
mitchellpkt超过 2 年前
A while back when I was familiar with coding but wanted to improve my python skills, I found this video helpful: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=qUeud6DvOWI">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=qUeud6DvOWI</a><p>Once I understood fstrings, list&#x2F;dict&#x2F;set comprehension, and tuple unpacking, it became much easier to read and learn from others&#x27; python code.
lazypenguin超过 2 年前
As with any programming language. Solve a wide range of different problems in different domains using different python tools.
pyuser583超过 2 年前
Read well written code. I recommend Django.
评论 #34830386 未加载
4dregress超过 2 年前
I&#x27;m self taught and on the cusp of becoming a senior engineer. I&#x27;ve improved by making mistakes and learning from my peers.<p>Review code and ask lots of questions, you wont learn anything if you don&#x27;t ask why?
roland35超过 2 年前
What forced me to understand more fundamentals was actually studying leetcode. It led me to learn more about data structures, things like itertools, and other other algorithms.<p>Combined with a good book (eg learn python the hard way) it’s an approach that worked for me.
评论 #34853000 未加载
aynyc超过 2 年前
Really really read the Python tutorial and library reference. I mean really read it. There are so much nuggets in there that you&#x27;ll be way above average Python developers by the end.
schwartzworld超过 2 年前
There&#x27;s no real shortcut to proficiency. Write a lot of code and always look for ways to improve it.
giantg2超过 2 年前
I didn&#x27;t.<p>I ended up going to a front end team working in Angular. Now I miss it.
评论 #34828618 未加载
thinking001001超过 2 年前
Learn C?
kidgorgeous超过 2 年前
leetcode puzzles. Will also help you get sharp for coding interviews
fegehrjhrh超过 2 年前
Stop using python. Learn a typed language and realise that whilst python is great for the odd script, it sucks for anything larger.<p>Rust to me is a better python, can make python modules (py03 ftw) and the 30x speed up you get from using it is great... Oh yeah there is a borrow checker but it is not that bad once you grok it.<p>Edit: autocompelete!!!!!!
评论 #34831838 未加载
评论 #34839163 未加载