40 comments

[ 0.18 ms ] story [ 102 ms ] thread
Customers want it. I like Java myself, but the Python ecosystem is similar in scope and quality. There is nothing really wrong with Python.
Easy to read, easy to write, great high-quality libraries for pretty much everything.
Good readable syntax, strong built-in data structures, good libraries for just about everything, less "magic" than other similar languages, moves at a deliberate pace and values backwards compatibility (minus the 2->3 thing).
For me, entirely because of python's large, referenced, and well-documented numerical libraries (e.g. scipy and numpy).
+1 I just discovered SciPy/NumPy. This library is brilliant, now I can forget all the matlab knowledge I had and just focus on Python.
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.

I just wish it supported the functional paradigm.

"The encoding is done using a function from the urllib library not from urllib2."

I love python. An ancient mess.

pandas. it's a killer library.
Scales small-to-medium codebases well. Modules and packages work well. PEP8. Linting tools like flake8.

Documentation is top tier. Docutils + Sphinx + ReadTheDocs. Autodoc and intersphinx (linking across python projects) are just wonderfully implemented.

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).

Standard library quality. Well documented and just the right amount of features in many cases. In some situations you may find more elegant API's in the contrib community.

OOP is implemented nicely. It scales well. It's easy to traverse large codebases and get situational orientation fast.

Language consistency. Python 3 is generally a consistent language. There are warts in every language, but nothing in python is insurmountable. Python 2.7 with __future__ imports and a compat module eliminates a lot of problems.

Debugging: Tracebacks are human friendly. ptpython/ptpdb and ipython/ipdb are a delight to work with.

C API integration. Well documented and well supported. Also see Cython, CFFI. Also C++ with boost python and pybind11

Editor integration. Jedi, pycharm

Stability. CPython (the main implementation) doesn'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's

Community. Friendly and great support on IRC and so on.

Because it is elegant.
Short answer: Python is the best high-level, general purpose language. It'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.

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].

[1]: https://news.ycombinator.com/item?id=9524607

[2]: http://web.archive.org/web/20161101070610/http://lisnr.com/b...

It'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.

The syntax is rich but concise. It doesn'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's portable.

Python isn'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't do that.

Because I'm told to for school.
Scipy, numpy, pandas. And it is easy to think in Python.
It looks like a general pseudocode, even someone unfamiliar with the language can read it and usually understand what's going on.
For business automation it's spectacular. Pandas dataframes make database queries and dynamic reporting easy. There are rich API examples for most services. It's free. It's portable between osx, Linux and windows.
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.
>as the life of the sane language version (Python 2) is going to end at some point.

Don't hold your breath for that. There are tens (hundreds?) of millions of Python code in production that's nobody ever gonna port, and that people will still support well into 2040.

So better job expectancy for Python programmers? :D
People still have to maintain Cobol programs, Python 2.x is not going to go anywhere.
I don't because it doesn't live up to its promises. Some of the most unreadable code I have seen was Python. Pure line noise.
I've never seen unreadable code in Python.

Care to post a sample?

And even if it actually was unreadable, just consider how the equivalent would look in Perl, or C (or APL...).

My point was that Python written by someone that don't know how to write readable code is just as unreadable as "sysadmin" Perl. Well written Perl is actually very readable.
Are you confusing Python with Perl? The latter prides itself on creating line-noise that works like magic. Python is meant to be super-readable.
Actually I find well written Perl more readable.
Yeah, I often blame the wood and nails when I see a poorly built house.
I use Python because of the people who made it what it is today. The community is what I like most about Python.

I'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's a global movement. I'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 try 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.

jupyter. nothing beats a repl in a web page for instant feedback and iteration.
simple but just as powerful as other OOP languages
The wide number of things it enables: data science & machine learning, web apps & APIs, simple scripts, and it doesn't trip beginners up with extra syntax.
It fits in my head. Its concepts are simple but orthogonal and extremely powerful. It doesn't ask me to take up complicated abstractions in order to do complicated things.

There's a library for everything out there.

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.

For the things where its performance is unsatisfactory, it offers escape hatches. The tooling is good; there's better out there but I rarely find myself yearning for more than ipdb.

For scientific computing, it's simply top notch. I can't see myself using anything else for doing my data analysis until you're pushing the limits of performance.

Tracebacks are clear. Unlike JS, I know exactly where a piece of code is failing.

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'd the one I feel most comfortable pushing until the point where you need stronger validation.

Because people hire for it. I use whatever I can get a job with easily.
It's clear, easy to read and junior developers can pick it up easily and contribute code sooner.