Stephen McInerney wrote: > Guys, > > I'm annoyed at how far offtopic and frankly rude the responses to my > email were, > and I'm just going to submit my doc change request to Fred Drake > exactly as > I was intending to before I sent the first mail. I have found your e-mails to be far more rude than those of the other list members. > I didn't get much decent opinion on my central question: > "isn't this idiom more restrictive than C/C++/Java (aka the rest of > the universe), I'm pretty sure a lot of people use .NET, Ruby, PHP, Perl, and other languages, so I wouldn't say C/C++/Java is the 'universe.' A large part, though. Yes, it's more restrictive. Python's 'for' loop has a specific purpose of iterating over collections. This feels similar to saying "Isn't the fact that you don't have direct access to the pointers that variables are storing more restrictive than C++?" It restricts you from accessing the pointers, this is true. However, it doesn't restrict you from anything you actually need to do. Python's aiming for the most common use-case of a for loop to be the clearest syntactically. > don't you agree it's badly explained in the doc (there is no basic > advice to transform > to while loop or else write generator), and the doc should have a > simple change > (add one or two lines with links is all that's needed)." Which doc is this? I don't think this addition would be a line or two. It's not simply "translate all your C++ for loops to while loops." There are particular situations where for loops are desired, and some where while are, and this requires a fairly in-depth discussion. > I made it clear that my motivation was that this is badly explained > and is a real > hurdle to migration. Then perhaps you should have avoided statements like "This is much poorer than C/C++" and "this is one area where Python is (syntactically) inferior to C/C++/Java. " Them's fighting words. It was completely unnecessary to use such strong language. You're not writing a college essay. We're not going to slap you on the wrists if you say things like "in my opinion." Just because you didn't put "in my opinion" doesn't change the fact that it is your opinion, and the list members disagreed with you. So they discussed why your statements were faulty.
If I said Your mother was a hamster and your father smelt of elderberries! How do I program hello, world! in Python? I'm pretty sure most of the focus of the ensuing discussion would fall upon whether your mother were, in fact, a rodent. > Show any of the code we discussed to non-Python > programmers and they'll be lost. Nobody attempted to address the valid > follow-on question about generators returning a tuple (e.g. walking a > pointer, > and incrementing a count, let alone anything more complex) > > - quibbling the motivation for the quicksort example I gave was > clearly offtopic; > I'm very well aware there are better Python implementions, that's > irrelevant; > the motivation was to give a legitimate example which clearly arises > commonly. I quite enjoyed the discussion. It was educational and it involved Python. It was in the spirit of the list, whether it followed your topic or not. Telling everyone off for discussing Python on a python tutor mailing list is not a good way to get the discussion back on track. You'll just get lots of e-mails like this one that, again, have no bearing on the original subject. > - nowhere did I ask for "the language to be changed". I made it clear > this > was a question about how the *documentation* *describes* the > Python approach (very badly describes). Again, these parenthetical criticisms are not doing you any good. They just piss people off. > In any case, when we talk about people migrating from other languages, > C/C++/Java is ~60-95% of the audience, COBOL is irrelevant and PL/I is > ancient history. > > - This is offtopic, but the C for-loop syntax is very syntactically > powerful, > so when people perceive Python lacks it, they may baulk at that. We > have to > do a better job selling why Python is better. The first time I used Python's for loop it was instantly clear that it was better to me. The same for all of my friends who I've introduced to Python. I think its ease of use speaks for itself and it's unnecessary to be preachy about it moreso than a simple explanation of the differences and the motivations behind the changes would be. > The C for-loop syntax itself is not error-prone at all. > Unless you mean off-by-one errors etc., missing initializations, and > those are mostly semantic not syntax-related. > Anyway most of those can be caught by trivial linting and code reviews, > and the rest by automated checkers. > > >> The C syntax is extremely odd to most programmers who haven't been >> trained in it but in more traditional languages like Lisp, Cobol, >> Fortran, Pascal, ADA, etc. > > I couldn't disagree more strongly. > Those were already dated in 1980 - almost everyone these days learns > C/C++/Java(/C#) > as their main programming language, unless they're mechanical > engineers or > accounting programmers. Look at TIOBE Index to confirm that. > > I am an EE who started out in the 80s with garbage like BASIC, > Fortran, Pascal and assembly, > but when I discovered C in 1992 I almost wept that the for-loop syntax > was so simple yet infinitely powerful. > >> But C is a poor choice for more user centric problems. > I never said otherwise, but the reality we're operating in is that the > common languages in use will always lag the leading edge by ~15-30 > years. So we should at least make very basic accomodations for that > migration reality. Specifically, give the people a hint to use > while-loops and generators. It seems like you have a pretty clear idea of what you want to be in the docs. So why don't you write it up and we'll critique it or something? Or did you want someone else to write it? >> > It's regrettable we have to choose between the clear and the >> > efficient, in this situation. >> >> The most clear and efficient is probably: >> >> myList.sort() > > Alan - this was totally unnecessary and trashes the entire > (legitimate) context of my question. Perhaps his reply was too succinct, but I felt it had a good point - for the common case when one just wants to sort a list, it's much easier to use the sort() method than to reimplement a sort. I understand your original example was just a case where a situation under discussion arose, and the sorting itself was irrelevant, but Alan's comment wasn't totally unnecessary. He's right, myList.sort() is much more clear and efficient. -Luke _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor