56

Other than being annoyed at whitespace as syntax, I'm not a hater, I just don't get the fascination with Python.

I appreciate the poetry of Perl, and have programmed beautiful web services in bash & korn, and shebang gnuplot. I write documents in troff and don't mind REXX. Didn't find tcl any more useful years ago, but what's the big stink about Python? I see job listings and many candidates with this as a prize & trophy on their resumes.


I guess in reality, I'm trying to personally become sold on this, I just can't find a reason.

15
  • 82
    I never understand why people get annoyed at Python's required indenting. I hope you were going to indent your code anyway, right? Sep 20, 2010 at 3:46
  • 11
    @GregH, of course, but shall my syntax be mandated by it? Kind of like Makefiles?
    – Jé Queue
    Sep 20, 2010 at 3:47
  • 5
    @Xepoch: But Makefiles don't just require indenting, they require a specific kind of indenting that's usually indistinguishable from the other kind. If Makefiles needed any whitespace indent instead of specifically 0x09, you probably wouldn't object and would probably use consistent indenting in your preferred indent width. This is the same thing Python allows. Sep 20, 2010 at 3:55
  • 31
    Poetry of Perl? Seriously? If you have had the honor of maintaining other people's Perl code, you would understand why Perl has fallen in terms popularity.
    – grokus
    Sep 20, 2010 at 14:03
  • 6
    @Greg, I agree with you. I said this before and I will say it again, whoever complains about Python's indentation rule should be asked to maintain poorly indented code. Just sayin...
    – grokus
    Sep 20, 2010 at 14:05

16 Answers 16

62

Python is a well-designed language with a reasonably clean syntax, a comprehensive standard library, excellent included and third party documentation, widespread deployment, and the immediacy of a "scripting" style language (ie. no explicit compile step).

8
  • 37
    Well-designed? Ever noticed that you have a global function called len? Sep 23, 2010 at 23:55
  • 67
    what is wrong with len? I get the impression you only read about python for 5 minutes
    – Kugel
    Nov 21, 2010 at 2:56
  • 5
    Personally, the language structure was so simple to grasp that it gave me a better understanding of how languages in general work internally. It's the little things. First class functions, ability to import only the relevant parts of a external module into the current, list comprehensions, tuples, the inclusion of self as a method parameter helped me understand the difference between functions and methods (other languages just hide behind sugar). It pains me to use languages like C# now because I know intuitively that the code isn't teaching me how anything about how it's working internally. Jan 17, 2012 at 7:01
  • 4
    How can python be a well designed language? It uses weird __double_underscore_names__, it mixes alllowercasefunctionames with mixed_underscore and mixedCamelCase names. It requires a : at the end of def or loops. It uses a lot of odd abbreviation str, dict, islice. It looks like there was no convention at all. It's a pure chaos. Peps, pips, zens... it's more like a python-religion then a language. It might have a few nice features but it doesn't explain why so many people are so over exited about it. There is nothing special about pyhon. Just another poorly designed product.
    – t3chb0t
    Feb 12, 2018 at 12:29
  • 1
    And what the hack is def? Why do I define a function with a def and not a func? There is no other languague that is as unintuitive as python.
    – t3chb0t
    Feb 12, 2018 at 12:33
78

I've found Python to be the most natural programming language that I've ever written code in. I've coded in a lot of languages before and after Python, and to a greater or lesser extent, you have to fight the language to get it to do what you want. Python reduces this struggle massively. Eric S Raymond said it much better than I can in Why Python?

As a related point, Python maintains its cleanness even while evolving rapidly. In most languages I've worked with, introduction of new language features introduces a lot of wrinkles. But with Python, even major language features (decorators come to mind) are added all the time, without feeling like ugly hacks.

4
  • 8
    Came here to say basically this. The syntax just feels so natural, it's almost like you're writing pseudocode. Sep 20, 2010 at 4:10
  • 2
    Python is compact: you can hold its entire feature set (and at least a concept index of its libraries) in your head. Sep 20, 2010 at 6:57
  • 2
    @Zoomzoom83 My pseudocodes have begins and ends -- it it not working in python :-(
    – mbq
    Sep 20, 2010 at 21:46
  • 1
    @mbq And my pseudocodes have braces, but that's another story ;) Sep 25, 2011 at 16:46
26

I hope this doesn't sound too cynical, but IMO Python is so popular for the exact same reason Java, C# and Objective-C are. Not because there's anything spectacular about the languages themselves, but because they've each got a magacorporate sponsor that's able to produce a lot of hype, a lot of advertising, and a lot of libraries and support for their preferred language.

9
  • 6
    C# is special, it has linq Sep 20, 2010 at 3:43
  • 39
    Python has a large corporation behind it? (genuine question)
    – Jé Queue
    Sep 20, 2010 at 3:45
  • 11
    Yeah, that's what I meant. Python was a whole lot less "cool" before Google started taking such an interest in it. Sep 20, 2010 at 4:17
  • 10
    @Mason - but surely, there must be some reason why a large corp like Google would make it "cool"?
    – Jas
    Oct 22, 2010 at 22:31
  • 7
    Why do people think there are corporate sponsors of python? Has anyone noticed the size of pycon versus the huge Java/j2ee conventions? This is a David and Goliath story of corporate funding.
    – rox0r
    Dec 20, 2010 at 15:55
11

My experience is that the people who find true joy in programming often seek a language that fits them better than what they learned at school or university. Basically this means that they will move from the default PHP / Visual Basic / C++ / Java / C# to something more exotic (business/careerwise) such as Python, Ruby, Haskell and even perl (because of it's enormous hack value and obscurity).

Don't get me wrong, there are very experienced C# / VB.net programmers who take great pride and joy in their work and code (the StackOverflow guys are a very good example), but you don't become a python programmer just because that's what they taught you in school; it has to be your own decision.

I think Jeff Atwoord had a blog post on this, but I can't find it. If I find it I'll update this comment.

2
  • 1
    Python was the first language taught at my school for 101. Jul 11, 2011 at 13:20
  • Almost every language has a reason to exist and is good at least at something. In my opinion this just says "I like it because others do".
    – NtFreX
    Feb 2, 2018 at 10:36
8

I started to love Python for the same reason that Eric S. Raymond describes: the act of writing programs in Python is conceptually very similar to thinking the act of designing code in my head.

Learning to be a good Python programmer made me a much better C# programmer. It made understanding LINQ much easier, for one. I might never have embraced a type like Dictionary<string, Func<T>>, or gotten comfortable using yield return, if I hadn't used classes and generators in Python. AOP is a lot easier to understand now that I've used Python decorators. The list goes on.

8

Compared to Ruby, which is really cool and produces amazing Code Golf-offs, Python has this core philosophy that "There should be one - and preferably only one - obvious way to do [things]," meaning the idiomatic Python way. I have found this to be a huge advantage compared to Ruby.

3
  • 4
    ..or compared to Perl with an seemingly infinite # of ways?
    – Jé Queue
    Oct 23, 2010 at 5:53
  • @Xepoch - actually, there's very often a lot less than infinity of good/correct ways of doing things in Perl, and most people with a clue will easily be able to tell you without TOO much disagreement what top 1 (or at most 2) are. if you don't believe me, look at Perl questions on SO. Yes, some quetsions have 10 distinct solutions. But most have a clearly agreed upon "most correct for circumstances" solution.
    – DVK
    Jan 13, 2011 at 18:56
  • @DVK, I know, but looking at it from a design goal.
    – Jé Queue
    Jan 13, 2011 at 20:31
6

Firstly, trifling language quirks like forced indentation in Python matters little if the language itself is powerfully expressive and useful. I was also turned away at first due to it, but soon learnt to look past it and now don't even feel it as a hindrance, because the language is so much easier for me to work in. Its like sigils in variables in Perl, its a harmless language quirk and anyone comfortable in the language don't feel bothered by it.

To understand the reasons why so many people think Python is great, just try and learn the language. The reasons are mostly the same as Perl. I find I like the syntax in Python (e.g. list comprehensions, OOP syntax, etc.), but that is really subjective and your opinion might differ. I prefer Python for larger projects, while I still use Perl for smaller scripts.

And that is the answer to your question. You compare Python to Perl, bash and tcl. The thing is that is that is not a fair comparison. Languages like bash was designed for writing small scripts to automate common tasks. Some people think Perl also gets unwieldy if the code gets sufficiently large (well written Perl does not, but well written code is hard to come by in a large project). IMHO Python differs from other 'scripting' languages in that it scales very well to large projects as well as small one-off scripts. I think Ruby also has that same quality.

6

The philosophy that the Benevolent Dictator should enforce his idea of good style[1], his idea of good programming, his idea of how to program frustrates me regularly. I don't think like van Rossum. However, his language resists attempts to express non-van Rossum thoughts. His thinking works really well for many (most?) programmers. But I seem to not fit into his model of how to program.

That is why I believe Perl is a superior language.

[1] See his blog about removing reduce.

2
  • can you please expound on your reasoning with the thought process, would like to hear more.
    – Jé Queue
    Oct 23, 2010 at 5:54
  • 3
    @Xepoch - a programming language serves as means of expression. Idioms and styles of thought can be expressed in a continuum of thought from 'fits' to 'very hard to fit'. For instance, I do not think in terms of list comprehensions. They are alien to how I think about problem solutions. But Common Lisp's reduce is something that flows without significant difficulty out of my mind. However, van Rossum evidently is the opposite. Java requires all things to be in objects. So it becomes very difficult to create non-object-oriented solutions in Java. And so on - Oct 23, 2010 at 15:04
5

I think to some degree Python is the only programming language you'll ever need, unless you want to write an OS kernel. It is suitable for the interactive use, random hacks, system administration, scientific applications, operating system tools, web applications, GUI applications, embedding, etc. etc., it's portable, free, and widely used. No other programming language really covers all those fields in practice. It's a really good strategic investment for a person and a company.

3
  • 4
    Not doubting Python here, but I think Perl fits your description above quite well if not better.
    – Jé Queue
    Sep 23, 2010 at 14:41
  • Ruby does very well at this too.
    – ocodo
    Sep 26, 2011 at 0:07
  • 1
    As of 2015, Python is the de facto general purpose language of scientific computing. Everything else is either the classical low-level stuff (C, C++, FORTRAN), competitive in a few niches (MATLAB, Mathematica, R, Julia, Lua), used for libraries and infrastructure only (Java), random scripting tools (bash, Perl) or.... well... none of the above.
    – Paul
    Dec 28, 2015 at 0:40
5

Since 2004, I've used Python to develop:

  • GUIs
  • Scripting ray tracer scenes with Python to C++ bindings
  • Cross platform automated build systems
  • Test scripts
  • General purpose tools to solve your everyday issues
  • Web sites and web apps

Back in 2004, Python was the language of choice because Python scripts are portable across Windows, Linux and Mac with very little modifications.

1
  • 4
    To quote a comment from different answer: "Not doubting Python here, but I think Perl fits your description above quite well if not better".
    – DVK
    Jan 13, 2011 at 19:00
4

To me Python has been a dear friend. It's a decent scripting and prototyping language. The key things I can think of are:

  • Clean syntax, very simplistic and easy to understand
  • Multi-paradigm, use it as a imperative language? Sure. OOP? No problem. It also has some light functional language features, e.g. lambda, list comprehensions, etc.
  • For basic computing needs, it has native support for the essential data structures, array, tuple, dictionary (associative array), set, etc.
  • Other features can make a programmer very productive, e.g. duck-typing, reflection, meta-programming, decorators, generators, etc.
  • Rich library support
4
4

It's elegant and really easy to learn, and once you're familiar with its basic types (especially lists) your productivity has no limit. It's perfect for prototyping algorithms, or for writing them in a pseudocode-like language that can eventually put directly on a machine, and it's really good as a scripting language for doing repetitive jobs or perform annoying operations on files. I use it as a glue language for making subprocesses communicate with each other: not as powerful as bash for some easy tasks, but WAY easier if you need to do more than just a single line of code.

And then it doesn't distinguish between functions and subroutines, you know what I mean.

3

Many Python lovers I see just switched from C surroundings and were impressed with stuff like "Hello "+ "World" is "Hello World". So I would say this is the first scripting language that does not gathered esoteric/specific tag and so spread around among martyred people like fire in a dried forest. And so created fashion now lives on its own.

2

Reapproaching the question now that I'm a little less tired:

Python is a language I've found particularly well suited for scientific programming tasks, which is one of the places where its popularity is growing pretty strongly. A few reasons why:

  • Fairly strong community support means there's some strong libraries in place, and Python works as a decent replacement for MATLAB and some of the other popular languages in that field.
  • It plays well with C when you do need speed, but often speed isn't really that necessary, so Python's interpreted nature isn't all that big of a deal.
  • I've found it to be a fairly approachable language without a huge number of what, to outsiders, feel like weirdly arbitrary syntax rules. It's pretty swift to translate between pseudo-code and Python.
  • "Take it or leave it OOP". A lot of scientific programming projects don't benefit all that heavily from extensive OOP. Some do. It's nice to have a language that can hop between the two easily.
  • Strong cross-platform support. Especially as what I work with rarely involves GUIs, I can pretty much rely on being able to send off a Python program to someone else without worrying about what OS they're running.

It's not the end-all, be-all of programming languages, but its a decent "Yeah, I probably have a tool to solve whatever problem comes up" language, which is probably why it's enjoying popularity at the moment.

1
  • Besides all other items you listed, I think one of the most important items was "I can pretty much rely on being able to send off a Python program to someone else without worrying about what OS they're running.". This is also very favorable when you don't want to get stuck with type of operating system.
    – Tarik
    May 1, 2014 at 17:40
1

Python is a very 'webby' language in both the frameworks available (Django, Zope etc) and in the easily importable libraries, which again cover many web functions.

For web developers making the move from just a HTML, CSS + JS skillset (anecdotally a large source of new programmers over the past few years), I think this makes it a very attractive proposition (ditto Ruby).

Also, Google isn't Microsoft....

1
  • Java isn't MS, so if your reasoning is correct, they would be moving to Java not python. There must be a different reason.
    – rox0r
    Dec 18, 2010 at 7:09
0

I think one of the main reasons is that 90% google is made from Python.

However, Python is also an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.

The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python Web site, http://www.python.org/, and may be freely distributed. The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional documentation.

The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). Python is also suitable as an extension language for customizable applications.

Not the answer you're looking for? Browse other questions tagged or ask your own question.