Hacker News new | past | comments | ask | show | jobs | submit login

• the language is easy, very attractive for non-CS people

• the language is consistent (everything is an object, or a pointer to an object rather, you can only pass by pointer, scope and namespace that make sense all the time, etc...)

• you can learn it gradually, you can start using it even if you know only 10% of the language

• Amazing documentation. The official tutorial is easy to read, and by the time you are through with it you are fairly proficient with python

• error message that tells you exactly what the error is and where it is happening. A lot of other languages do that now, but that wasn't the case 25 years ago.

• inline help / magical docstring (`a=4 ; help(a)`)

• The REPL, especially being able to get into the REPL with your apps (`python -i`)

• batteries, again 25 years ago, no language came with such a huge standard library

• PEP 8, the grandfather to gofmt and rustfmt. Makes a big difference when working on a team

• the Zen (`import this`)

And of course as the language grew in popularity:

• the ecosystem (pypi.org)

• the amount of resources, from books to website, the answer to every questions you can think of in SO, very active and helpful mailing list/usenet group, active and helpful /r/Python




Scope and namespace that make sense all the time?

  for foo in bar:
    pass
  # Why is "foo" in scope here???


Because Python doesn't have block scoping, only function scoping.


Yes, my point is that function scoping can hardly be described as "makes sense all the time". Especially given that variable declarations in python are _very_ implicit, without even the "var" that will indicate to you that you're messing with your function scope in JavaScript.


> Yes, my point is that function scoping can hardly be described as "makes sense all the time".

Block and function scoping both "make sense all the time." Whether or not you personally are accustomed to a language's design decisions does not have any bearing on whether or not those decisions "make sense."

In the particular case you cited, of course it is natural that `foo` is in scope outside of the loop; it appears in a line outside of the loop. This is trivially evident in the indentation.


The context is that we're talking about people picking up the language for the first time, coming from other languages. What matters is whether the scoping rules make sense to such people.

For that, it matters whether they're coming from another function-scoped language (or are familiar with one), and whether they're used to having their variable declarations being obvious or not.

For me, when I was first learning Python, this scoping issue was a significant pain point. This is obviously an anecdote, not data, but again for purposes of "people first coming to the language" it's relevant.

Obviously once one has worked in Python for a while one internalizes things like this, just like one internalizes various things in other languages that are obvious pain points for beginners.


Python is and always has been designed to be an introductory programming language, so your criticism does not apply in the case of this design intent. More people learn Python first than learn another language first. Having seen beginning programmers learn Python, I can say this is an utter nonissue to them.

For the case of experienced programmers, the behavior is consistent and simple. In what way does this not "make sense?" Does Haskell's normal order evaluation not "make sense?" Does Ruby's optional parentheses for method calls not "make sense?" Does a regular expression literal syntax not "make sense?" Does JSX not "make sense?" Do public/protected/private modifiers in Java not "make sense?"

Stop confusing a match to your personal comfort zone for actual quality or fitness-for-purpose.


> the behavior is consistent and simple

Let's look at our example again:

  for foo in bar:
    pass
  # Why is "foo" in scope here???
Well, the answer could be "it's not". It depends on whether bar actually produced anything to assign to foo. Doing a "print(foo)" after that loop might print something, or it might throw a NameError.

Now I understand why that happens (in terms of what the loop actually desugars into), and you understand why it happens. But it's not as consistent and simple as you're trying to make it out to be. You have to really understand what a for-in loop is doing under the hood to explain the behavior.

You seem to feel that I'm attacking Python or something. I'm not. It's a nice language to work in, with a lot to recommend it. But it's not a language I'd choose as a poster child for scope and namespace making sense all the time unless you really dig into what's going on "under the hood".

> Does Haskell's normal order evaluation not "make sense?"

No opinion, really; not enough intimate familiarity with the problem space to have one.

> Does Ruby's optional parentheses for method calls not "make sense?"

Again, no opinion.

> Does a regular expression literal syntax not "make sense?"

It depends on the regexp. If your regexp is simple enough, it's fine. In far too many cases you end up with a write-only monstrosity. Also, you say "syntax" as if there were only one; there are multiple and some make more sense than others.

> Does JSX not "make sense?"

Again, no opinion.

> Do public/protected/private modifiers in Java not "make sense?"

It depends on how they're used.

> Stop confusing a match to your personal comfort zone for actual quality or fitness-for-purpose.

Stop confusing "doesn't always make sense" for "doesn't make sense" (totally different statements, there), and the former statement for a statement about quality of fitness-for-purpose. Lots of things are considered high-quality and fit for purpose while still having flaws. Possibly flaws that could not have been avoided without sacrificing other goals. But determining that requires first admitting that the flaws exist and then evaluating them. If we either pretend that the flaws don't exist, or that flaws existing is somehow an indicator that the entire system is unfit for purpose, it's hard to think productively about the design of the next system.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: