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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: Why use Python?

42 点作者 xcoding大约 8 年前

30 条评论

git-pull大约 8 年前
Scales small-to-medium codebases well. Modules and packages work well. PEP8. Linting tools like flake8.<p>Documentation is top tier. Docutils + Sphinx + ReadTheDocs. Autodoc and intersphinx (linking across python projects) are just wonderfully implemented.<p>Contrib Library quality. Mature and well documented. Permissively licensed. Django, SQLAlachemy, Requests, Flask, Werkzeug, Boto, Jupyter, Numpy, Pandas, Scipy, fabric, ansible, saltstack, pytest (a new favorite of mine).<p>Standard library quality. Well documented and just the right amount of features in many cases. In some situations you may find more elegant API&#x27;s in the contrib community.<p>OOP is implemented nicely. It scales well. It&#x27;s easy to traverse large codebases and get situational orientation fast.<p>Language consistency. Python 3 is generally a consistent language. There are warts in <i>every</i> language, but nothing in python is insurmountable. Python 2.7 with __future__ imports and a compat module eliminates a lot of problems.<p>Debugging: Tracebacks are human friendly. ptpython&#x2F;ptpdb and ipython&#x2F;ipdb are a delight to work with.<p>C API integration. Well documented and well supported. Also see Cython, CFFI. Also C++ with boost python and pybind11<p>Editor integration. Jedi, pycharm<p>Stability. CPython (the main implementation) doesn&#x27;t break. Clear distinction between 2 and 3 and easy enough to code to both versions. Contrib libraries generally follow semver and have consistent API&#x27;s<p>Community. Friendly and great support on IRC and so on.
tedmiston大约 8 年前
Short answer: Python is the best high-level, <i>general purpose</i> language. It&#x27;s got a good following in web apps and APIs, data processing and research, and many other fields, as well as being the language of choice for many glue code projects and as a modern alternative to bash scripts.<p>I wrote a post that was popular on HN a few years ago thinking out loud about what Python is good at which received several comments on areas I missed too. The link in the HN thread [1] is dead but you can find the post at [2].<p>[1]: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9524607" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9524607</a><p>[2]: <a href="http:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20161101070610&#x2F;http:&#x2F;&#x2F;lisnr.com&#x2F;blog&#x2F;pycon-2015-are-we-still-changing-the-world&#x2F;" rel="nofollow">http:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20161101070610&#x2F;http:&#x2F;&#x2F;lisnr.com&#x2F;b...</a>
cauterized大约 8 年前
It&#x27;s mature. The community is mature (in multiple senses of the word). The ecosystem is mature. The package management is solid. There are drivers or SDKs for basically every tool or service I would want to interface with.<p>The syntax is rich but concise. It doesn&#x27;t require compilation of binaries. It does OOP pretty well. It does procedural pretty well. It does web pretty well. It does throwaway command line scripts pretty well. It does performance well enough for the things I do with it. It&#x27;s portable.<p>Python isn&#x27;t perfect, but 99.99% of the time it gets out of my way. I must, can, and do work with other languages. I constantly find them frustrating me in small ways. Python generally doesn&#x27;t do that.
mattbillenstein大约 8 年前
Good readable syntax, strong built-in data structures, good libraries for just about everything, less &quot;magic&quot; than other similar languages, moves at a deliberate pace and values backwards compatibility (minus the 2-&gt;3 thing).
jMyles大约 8 年前
Lots of great answers here, but I think that there is an underlying cause of most of the benefits described, and that there is &quot;one obvious way&quot; to think about this question, and it&#x27;s this:<p>* Python lives outside the control of any single corporate or government entity. Yes, three of the biggest players work at Dropbox, but clearly Dropbox doesn&#x27;t have the kind of control over Python that Oracle has over Java, SalesForce with Ruby, or Google with Go.<p>Because of this, Python is more a community than a single programming language. Being at PyCon fills one with the sense that, after the fall of the state (or at least the US government), very little will change within Python - we&#x27;ll still be there to support each other in code and in spirit.<p>There will still be a space for data science and web trends to share air with multimedia hacking and sacred geometry. There will still be story telling, acro-yoga, robotics, and unit tests under one roof.<p>I can actually imagine Rust or Go (and Gophercon) becoming such a haven, but to my knowledge, it isn&#x27;t yet. Python has the unique combination of a rich, diverse, radical, accepting culture with technical maturity and reliability.<p>Python makes me feel safe and brings out the best of who I am.<p>That&#x27;s why I use Python.
cdnsteve大约 8 年前
It&#x27;s a top-tier language due to the amazing support it receives from companies and the community. The PSF is well organized and the language releases are stable. There aren&#x27;t a massive number of releases (or security issues) to try and keep up with but enough where new features are being added. It&#x27;s usually one of the first languages to receive love when a new service is rolled out in terms of a library or offering. Tooling is good, using Visual Studio Code.<p>It&#x27;s on an uptrend on usage which is always good for your career. I use it for web apps and API&#x27;s and many larger companies also use it like Uber, Rackspace, Twillio, etc. The scientific field is becomming larger and it seems to be growing extremely quick with a new momentum in AI. Great option for building a CLI tool out. Overall it can handle a lot.<p>It&#x27;s a language I really enjoy using on a daily basis at work. It feels like it has been the result of lots of hard work from some really smart people. Our team was at a crossroads and tried a variety of languages, we all agreed on Python. Clarity of what&#x27;s happening with code is important to us and Python excels in this area.
Daishiman大约 8 年前
It fits in my head. Its concepts are simple but orthogonal and extremely powerful. It doesn&#x27;t ask me to take up complicated abstractions in order to do complicated things.<p>There&#x27;s a library for everything out there.<p>I have never seen a language with greater uniformity of styles and idioms, with those style choices being right the vast majority of the time. You generally know what to expect, and I spend little time fighting with bugs or surprising behaviors.<p>For the things where its performance is unsatisfactory, it offers escape hatches. The tooling is good; there&#x27;s better out there but I rarely find myself yearning for more than ipdb.<p>For scientific computing, it&#x27;s simply top notch. I can&#x27;t see myself using anything else for doing my data analysis until you&#x27;re pushing the limits of performance.<p>Tracebacks are clear. Unlike JS, I know exactly where a piece of code is failing.<p>It lets you break rules when you need it to but it makes it obvious and the cultural pressure to not do it is high. Out of all the dynamically typed languages I know it&#x27;d the one I feel most comfortable pushing until the point where you need stronger validation.
Dowwie大约 8 年前
I use Python because of the people who made it what it is today. The community is what I like most about Python.<p>I&#x27;m bootstrapping, taking a one-man army approach to creating a new service. I chose a mature language with features and open source projects I may possibly want or need along the way. I am working alone -- not by preference but rather necessity -- and knew I would need help along the way (started very green, 4 years ago). The Python standard library and open source ecosystem offers everything and more than I may ever need to create my vision. The Python community is really strong. It&#x27;s a global movement. I&#x27;ve gotten so much help on IRC! Stack overflow always has an answer or a legion ready to answer practically anything Python related. Years of Python related blog posts are a google search away from access. PSF-supported Python conferences release or at least <i>try</i> to release video recordings of talks (cough.. ehem..). As for conferences? PyCon has been the ooey gooey salted caramel center of the perfect vanilla pint.
type0大约 8 年前
It looks like a general pseudocode, even someone unfamiliar with the language can read it and usually understand what&#x27;s going on.
oyebenny大约 8 年前
Because I&#x27;m told to for school.
theophrastus大约 8 年前
For me, entirely because of python&#x27;s large, referenced, and well-documented numerical libraries (e.g. scipy and numpy).
评论 #14013831 未加载
arms大约 8 年前
I use Python because:<p>- it&#x27;s a well designed language<p>- it has a great ecosystem and community<p>- it runs fast (enough for my purposes)<p>- it looks enough like pseudo-code that translating what I wrote on paper into a program is that much simpler.<p>The fact that it can be used both for teaching computer science in colleges and children how to code speaks volumes about its versatility and approachability.<p>I use it mostly for web apps, APIs and miscellaneous scripts. Python has been a great addition to my tool-belt. There are some languages I hope I never have to write again; Python on the other hand is something I&#x27;m going to always keep in mind, even if I spend most of my days writing another language.
rrggrr大约 8 年前
For business automation it&#x27;s spectacular. Pandas dataframes make database queries and dynamic reporting easy. There are rich API examples for most services. It&#x27;s free. It&#x27;s portable between osx, Linux and windows.
sparkling大约 8 年前
Easy to read, easy to write, great high-quality libraries for pretty much everything.
pryelluw大约 8 年前
It works well,is not handicapped by verbose idioms, works on most platforms and environments, can glue together other technologies, and the community is pretty good.<p>I just wish it supported the functional paradigm.
meagher大约 8 年前
The wide number of things it enables: data science &amp; machine learning, web apps &amp; APIs, simple scripts, and it doesn&#x27;t trip beginners up with extra syntax.
PaulHoule大约 8 年前
Customers want it. I like Java myself, but the Python ecosystem is similar in scope and quality. There is nothing really wrong with Python.
paultopia大约 8 年前
jupyter. nothing beats a repl in a web page for instant feedback and iteration.
marchenko大约 8 年前
Scipy, numpy, pandas. And it is easy to think in Python.
LordHeini大约 8 年前
CiPy. Simply the best option if you want to plot and manipulate your data in whatever way possible without any assle(most of the time).
drewjaja大约 8 年前
It&#x27;s clear, easy to read and junior developers can pick it up easily and contribute code sooner.
ransom1538大约 8 年前
&quot;The encoding is done using a function from the urllib library not from urllib2.&quot;<p>I love python. An ancient mess.
BoysenberryPi大约 8 年前
Because people hire for it. I use whatever I can get a job with easily.
loblollyboy大约 8 年前
Better question is why you wouldn&#x27;t
apetrov大约 8 年前
pandas. it&#x27;s a killer library.
slrz大约 8 年前
I try to avoid it for new programs though, as the life of the sane language version (Python 2) is going to end at some point.
评论 #14014599 未加载
评论 #14014871 未加载
评论 #14016460 未加载
jmstfv大约 8 年前
Because it is elegant.
rtiwary大约 8 年前
simple but just as powerful as other OOP languages
jwilk大约 8 年前
Inertia.
vgy7ujm大约 8 年前
I don&#x27;t because it doesn&#x27;t live up to its promises. Some of the most unreadable code I have seen was Python. Pure line noise.
评论 #14015365 未加载
评论 #14014876 未加载
评论 #14015228 未加载