News for hackers. Stuff that matters.
Re:This Is What Python Beginners Have to Deal With by huskyr on Thursday September 08, 2016 @06:37AM (#12451756)
Quoting myself from a blog post i wrote when i was learning Python two and a half years ago [1]:

Let’s say i want to know how to do the Python equivalent of PHP’s foreach. The docs about the for statement say this:

    The for statement is used to iterate over the elements of a sequence (such as a string, tuple or list) or other iterable object:

    for_stmt ::=  "for" target_list "in" expression_list ":" suite
          ["else" ":" suite]
Right, so what does that mean? What’s ::=? What’s an ‘expression list’?

    The expression list is evaluated once; it should yield an iterable object. An iterator is created for the result of the expression_list. The suite is then executed once for each item provided by the iterator, in the order of ascending indices.
“Ascending indices”? “Suite”? This might be clear for a CI professor, but it’s not for the mere mortals that read the docs and want to get stuff done.

Things haven't gotten much better since then.

[1]: https://www.haykranen.nl/2014/02/12/saying-hello-to-python-s...

Re:This Is What Python Beginners Have to Deal With by jacobolus on Thursday September 08, 2016 @06:43AM (#12451779)
You were reading the wrong docs for a newbie. The language reference is intended for people who want a very concise and precise technical document, not an introductory explanation. If you read the very beginning, the language reference is very clear about what it is and isn’t:

> This reference manual describes the syntax and “core semantics” of the language. It is terse, but attempts to be exact and complete. The semantics of non-essential built-in object types and of the built-in functions and modules are described in The Python Standard Library. For an informal introduction to the language, see The Python Tutorial.

You should have been looking at the Python Tutorial instead.

https://docs.python.org/3/tutorial/controlflow.html

https://docs.python.org/3/tutorial/datastructures.html#loopi...

Re:This Is What Python Beginners Have to Deal With by jawbone3 on Thursday September 08, 2016 @07:49AM (#12452124)
Another nice example of what the author complains about, a "it's your own fault" reply whenever someone complains that the official language docs are hard to understand.

Personally I almost never find any use from the docs whenever they come up in a google search, its almost as bad as those expert-exchange hits that used to appear. The core issue being that pythons docs are only a language reference for the vast majority of the standard library, and the size of the stdlib bein one of pythons strengths.

Re:This Is What Python Beginners Have to Deal With by makomk on Thursday September 08, 2016 @03:15PM (#12456322)
Personally, as a 16 year old (or possibly younger, it was a long time ago) with no internet connection and little programming experience I found the Python user documentation very helpful. That possibly had something to do with me actually reading the tutorial rather than dismissing it as beneath me or ignoring it altogether and attacking the person who brought it up.
Re:This Is What Python Beginners Have to Deal With by jawbone3 on Thursday September 08, 2016 @05:17PM (#12457411)
Well, the discussion is about the docs recently available online, so you finding a python book helpful in the times when no python shell autocompleted is a bit outside the topic at hand.
Re:This Is What Python Beginners Have to Deal With by makomk on Thursday September 08, 2016 @06:15PM (#12457875)
I'm talking about exactly the same documentation and the same tutorial that's available online (well, obviously it was a much older version of it). Only difference is that the offline version is a directory of local HTML files rather than a website. The user experience is pretty much the same with both. Still pretty handy even in the StackExchange era, though it'd be more useful if Google didn't keep finding the wrong version of the docs (2.x when I'm using 3.x or vice-versa).
Re:This Is What Python Beginners Have to Deal With by jacobolus on Thursday September 08, 2016 @09:37PM (#12459087)
It’s not “it’s your own fault”, but rather “you should read the document you’re looking at, and think critically, instead of expecting that every google hit is going to be precisely what you are looking for right off the bat, with no need to scroll or read”.

If the author had gone on the Freenode #python IRC channel or the Python Users mailing list (or..., or...) and asked “Hi, I’m a newcomer trying to understand Python loops, what’s the best resource?” someone could have linked him to the tutorial. Or if he’d done a google search and tried skimming a few hits, he would have found it.

It’s hopeless to expect that every single document in the world will be tailored for every reader.

There’s a real value to a concise and precise technical document aimed at folks who need something closer to a specification than to an introductory explanation. It would be net-negative to remove the language reference from the internet, or clutter it up with a bunch of information that can easily be written somewhere else.

Imagine someone wanted to understand the basics of how levers and pulleys work, and they came across a quantum mechanics textbook, which wasn’t comprehensible at their current level of understanding. Should the reader blame the book, or keep looking for a more appropriate source?

Re:This Is What Python Beginners Have to Deal With by huskyr on Thursday September 08, 2016 @08:41AM (#12452408)
Sure, in a perfect world i would read the complete tutorial before i get started on a new language.

But it's not a perfect world, i want to get stuff done. I have twenty years of programming experience, i don't need to learn what a for loop is (the first link) and i don't want to read a whole document just to find a reference to the items() function (second link). I just want to know what the equivalent of foreach() is in Python.

Sure, a document with a 'very concise and precise' technical description might be useful to some, just for looking up things it's not. The current alternative is Googling StackOverflow posts.

Re:This Is What Python Beginners Have to Deal With by junke on Thursday September 08, 2016 @09:02AM (#12452529)
Sure, in a perfect world the documentation would guess who I am and adapt accordingly, be both highly detailed when I need it or informal when I don't.

But it's not a perfect world, I want to get stuff done. I have twenty years of programming experience, I know how to find the information I need.

Sure, the whole language explained in one place for all kind of people from beginners to experts would be nice. But I have Internet. I type "foreach python" in Google and I see a StackOverflow post.

Re:This Is What Python Beginners Have to Deal With by lawpoop on Thursday September 08, 2016 @12:08PM (#12454300)
> I type "foreach python" in Google and I see a StackOverflow post.

That's kind of indicative right there.

Re:This Is What Python Beginners Have to Deal With by junke on Thursday September 08, 2016 @12:19PM (#12454407)
Indicative of what?

Are you trying to say that a the docs should have "Python for X programmers" sections, foreach (no pun intended) X in {Perl, PHP, Haskell, Lisp, Go, Javascript, C++, ...}?

That would be nice, but what is even better is a totally different resource that aggregates idioms for all languages:

https://www.rosettacode.org/wiki/Loops/Foreach

Re:This Is What Python Beginners Have to Deal With by lawpoop on Thursday September 08, 2016 @02:37PM (#12455884)
That the first result is a stackoverflow question about the language rather than a documentation page, is indicative that getting started with the language is not so straight-forward, even factoring in documentation.

If you're googling 'python foreach', you're probably at the beginner level, and the fact that a documentation page is not the first result means that the beginners documentation is not very discoverable.

The fact that there's a not-closed, highly-upvoted, highly-ranked stackexchange question about this very basic issue in existence /at all/ is what one might call a "documentation smell".

Re:This Is What Python Beginners Have to Deal With by junke on Thursday September 08, 2016 @03:17PM (#12456342)
The documentation contains "for-each" and "for each", but sadly not "foreach". Why should "foreach" be in the documentation? There is no "foreach" keyword in Python. If you are looking for "foreach", someone else will look for "python do until", "python fold", "python switch" and maybe another one for "python macros" or "python transducer".

Some of those searches are legitimate, because "foreach" is quite used outside of Python and "switch" should be expected to be defined in every language. However, the documentation states what the language is, not what it isn't.

The goal of a reference documentation is like a dictionary: you define your words w.r.t. the other words defined in your language; this is already quite a complex task. But you don't mention words from other languages because that would start to be overly confusing and a burden to maintain (now you have to check how other languages evolve). There are other resources to make connections between languages.

Re:This Is What Python Beginners Have to Deal With by lawpoop on Thursday September 08, 2016 @05:25PM (#12457485)
> Why should "foreach" be in the documentation?

To make it easier to find "for", "for each", and "for-each"?

Re:This Is What Python Beginners Have to Deal With by junke on Thursday September 08, 2016 @11:52PM (#12459534)
How come you know "foreach" in the first place, this is not even a correct english term? You learn it from another language? Wonderful, but why should every keyword from every programming language ever designed be present in the Python docs?
Re:This Is What Python Beginners Have to Deal With by lawpoop on Friday September 09, 2016 @11:30PM (#12467540)
I never argued for every for every keyword from every programming language. But like I said, that there's a stackoverflow question about this one, I think, is indicative.
Re:This Is What Python Beginners Have to Deal With by junke on Monday September 12, 2016 @04:37AM (#12478070)
And this one is special because?
Re:This Is What Python Beginners Have to Deal With by falcolas on Thursday September 08, 2016 @09:17AM (#12452658)
With all due respect, if you have 20 years of programming experience and can't grok BNF, it might be worth stopping attempting to learn new languages and learn BNF instead. Given than BNF defines how Python (and many other languages) is parsed, it's well worth learning.
Re:This Is What Python Beginners Have to Deal With by jacobolus on Friday September 09, 2016 @05:14AM (#12460590)
Actually, the folks with 20 years of experience in other languages are the ones who most need to read the Python tutorial.

The python code I read from PHP/Java/C++/... “career experts” tends to be worse than the python code I read from people who have only been programming for 2–3 years, because they never bother to learn Python idioms or style, but just keep on writing code in the same old style in every language.

It’s certainly possible to dive into a new programming language and start writing nominally working code right away, filling in with a google search whenever you get stuck.. That’s not a way to ever end up with any kind of basic competence in the language though. It also doesn’t give you much of a leg to stand on for complaining.

The Python tutorial is short and breezy, a fast read which will put you well on your way to understanding the language. I’d recommend it for anyone who plans to spend more than a day or two reading or writing Python code.