LWN: Comments on "PyCon: Evangelizing Python" http://lwn.net/Articles/544290/ This is a special feed containing comments posted to the individual LWN article titled "PyCon: Evangelizing Python". hourly 2 PyCon: Evangelizing Python http://lwn.net/Articles/546277/rss 2013-04-06T19:42:36+00:00 chrisV <div class="FormattedComment"> "But generators have a problem: they are a "bad date". Like a date that can only talk about themselves, generators can only talk, not listen. That led to the idea of two-way generators. Now generators can accept inputs in the form of send(), throw(), and close() methods. It is a feature that is unique to Python"<br> <p> Except that it isn't. This has been available in spidermonkey's ECMAscript implementation for ages (since 1.7?). Any language which provides delimited continuations can implement this, which includes GNU guile's scheme implementation (where I have working code which does this), and no doubt most of the other functional languages can do something similar.<br> <p> </div> PyCon: Praising Python for all the wrong reasons http://lwn.net/Articles/546271/rss 2013-04-06T16:18:51+00:00 jake <div class="FormattedComment"> For Lisp-Python mashups, Hy might be of interest:<br> <p> <a rel="nofollow" href="http://code.activestate.com/lists/python-announce-list/9602/">http://code.activestate.com/lists/python-announce-list/9602/</a><br> <p> jake<br> </div> PyCon: Praising Python for all the wrong reasons http://lwn.net/Articles/546264/rss 2013-04-06T16:01:39+00:00 pboddie <div class="FormattedComment"> Your mention is the only trace of "Steel Bank Common Python" I can find on the Internet using Google. Meanwhile, I am aware of CLPython which may or may not now run on SBCL (given that I haven't checked CLPython's status for a while).<br> </div> Most computers running Windows? http://lwn.net/Articles/546254/rss 2013-04-06T13:13:34+00:00 hummassa <div class="FormattedComment"> <font class="QuotedText">&gt; "A computing device in every pocket"</font><br> <p> Is it funny to remember that the first time I read something like that was in Bill Gates' book?<br> </div> Most computers running Windows? http://lwn.net/Articles/546251/rss 2013-04-06T12:16:52+00:00 Duncan <div class="FormattedComment"> <font class="QuotedText">&gt; most of the computers in the world are running Windows</font><br> <p> I'm surprised nobody else seems to have commented on this so far. I thought most computers were running Linux these days, with Android pushing Linux over the top?<br> <p> Not that I've cared enough to actually track it myself, but that's the impression from what I've read. But even if it's a plurality not a majority, I believe it has been awhile since the MS slogan of "A computer on every desktop" has been supplanted by (roughly speaking) "A computing device in every pocket", and most of those, as well as most of the servers serving them, as well as a good portion of the routers routing between the two, run Linux. MS may still rule the desktop, but the desktop's only a small portion of the computing world these days, and getting smaller literally by the minute.<br> <p> Of course the claim wouldn't be our editor's fault, rather the fault of the guy doing the presentation (and thus making the claim) being covered. Tho it's still disruptive enough a claim as to merit an editorial parenthetical or footnote disclaimer, I'd think. It certainly was here.<br> <p> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546204/rss 2013-04-05T19:47:46+00:00 andrel <div class="FormattedComment"> Pypy is written in Python. More precisely a restricted subset of Python called RPython.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546199/rss 2013-04-05T18:41:36+00:00 HelloWorld <div class="FormattedComment"> Oh, so Python is worse to read than Prolog because it's dynamically typed? Yeah, that makes sense. Oh wait, it doesn't: Prolog is also dynamically typed!<br> <p> By the way: C is neither high-level nor strongly-typed. Sometimes it's better to remain silent, you know...<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546134/rss 2013-04-05T13:49:41+00:00 XTF <div class="FormattedComment"> I didn't mention wonderful at all. Just wanted to state that apparently C is still the best choice in certain cases.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546119/rss 2013-04-05T13:27:30+00:00 XTF <div class="FormattedComment"> [quote] Or worse you have a long running python process that hits a section of code after days of running and it blows up in there and you have to figure out wtf went wrong.[/quote]<br> In that case you've probably chosen the wrong tool for the job.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546117/rss 2013-04-05T13:25:35+00:00 renox <div class="FormattedComment"> CPython is written in C, C is often the best tool to use because of many reasons (availability of compilers/of developers, performance, etc), but this doesn't make it a "wonderful" language..<br> Unless by "wonderful" you mean "full of undefined behaviours just waiting to hurt the developers" ( <a href="http://blog.regehr.org/archives/category/compilers">http://blog.regehr.org/archives/category/compilers</a> ) in which case I agree.<br> <p> <p> <p> <p> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546116/rss 2013-04-05T13:15:23+00:00 XTF <div class="FormattedComment"> So what language does Python use for it's implementation? C++?<br> </div> PyCon: Praising Python for all the wrong reasons http://lwn.net/Articles/546114/rss 2013-04-05T12:59:17+00:00 gvy <div class="FormattedComment"> <font class="QuotedText">&gt; Lisp isn't even on the radar for being a competitor to Python.</font><br> Yeah, especially given Steel Bank Common Python. Crap, the radar you use must be from '60s!<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546110/rss 2013-04-05T12:26:53+00:00 ThomasBellman <div class="FormattedComment"> <font class="QuotedText">&gt; as the Miranda language uses indentation and predates Python</font><br> <p> And occam a couple of years before that.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546096/rss 2013-04-05T08:42:39+00:00 intgr <div class="FormattedComment"> <font class="QuotedText">&gt; there is nothing that visually tells you anything</font><br> <p> Note that this is fixed in Python 3, it gives you a "TabError: inconsistent use of tabs and spaces in indentation"<br> <p> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546081/rss 2013-04-05T07:02:03+00:00 dlang <div class="FormattedComment"> any language that requires me to have a specific configuration in my editor to use the language is not a reasonable choice.<br> <p> If you are a full-time programmer who works in a nice, dedicated environment, you may end up with a nice tailored config.<br> <p> But, like most sysadmins, I have to support software on all sorts of systems, many of which I haven't ever touched 5 minutes before I'm working on the code.<br> <p> by the way, this is why I'm a vi person. every system has some variation of vi that I can run to get the job done. other editors, it's not the same thing.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546078/rss 2013-04-05T06:19:41+00:00 smurf <div class="FormattedComment"> So set up your editor that your tabs actually do the same thing, visually, that Python thinks they do logically. Simple.<br> Or tell your editor to not use tabs at all. Again, simple.<br> Or tell your editor not to use spaces (i.e. ony Python indent == 1 tab) and make the tabs wide enough that you can't miss any misalignment.<br> <p> The Python community has more-or-less agreed on the second option; personally I strongly prefer the third. But that's as much bikeshedding as whether a C open brace goes on the same line as the if statement, or below it (and if so, which indent does it get?)<br> <p> This kind of mistake (mixing up tabs and spaces) is so easy to check for that Python actually has an option for it. Which C compiler checks for "wrong" indentation on nested statements?<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/546075/rss 2013-04-05T04:16:45+00:00 welinder <div class="FormattedComment"> <font class="QuotedText">&gt; You simply don't get to make these mistakes in Python. </font><br> <p> That's actually wrong.<br> <p> When a tab sneaks in you so get to make those mistakes and there is<br> nothing that visually tells you anything. Things line up neatly,<br> but don't actually work.<br> <p> In C you don't get to make those mistakes. If it's important<br> then you can see it.<br> <p> </div> Python vs JavaScript http://lwn.net/Articles/546034/rss 2013-04-04T20:42:48+00:00 joib <div class="FormattedComment"> I've been toying with the idea of playing around with node.js when I get some time. But I wonder, how well does it do for "normal" scripting stuff? I'm sure it's a nice tool for building socket servers, proxies and so on, but how suitable is it for stuff outside that niche? Stuff like parsing text, csv files, connecting to databases (ldap, sql, ...), access to POSIX functions, etc.?<br> <p> In addition to the above, personally in python land I've used numpy/scipy/matplotlib extensively to do calculations and plotting stuff; AFAICT javascript/node/npm doesn't have anything coming close to those. But in the grand scheme of things that's perhaps a somewhat esoteric use case. Then again, servers capable of handling tens of thousands of concurrent connections seem pretty esoteric as well (to me, at least!)..<br> </div> Python vs JavaScript http://lwn.net/Articles/545871/rss 2013-04-04T07:52:40+00:00 man_ls <blockquote type="cite"> You are comparing a "batteries included" language with one that doesn't have a standard library. </blockquote> True for JavaScript, but node.js does a good job of supporting a fair <a href="http://nodejs.org/api/">standard library</a>. Python vs JavaScript http://lwn.net/Articles/545866/rss 2013-04-04T07:04:54+00:00 sayap <div class="FormattedComment"> <font class="QuotedText">&gt; To this day the default packages carried by Debian and Mac OS X (the two operating systems I use) are 2.x, so there is little incentive to upgrade most libraries.</font><br> <p> Debian Python maintainer is not very good at his job: <a rel="nofollow" href="http://lwn.net/Articles/496335/">http://lwn.net/Articles/496335/</a> Be grateful that you even have Python 2.7. Also, a quick Google search shows that MacPorts has packages for Python3.<br> <p> <font class="QuotedText">&gt; On to the subject of the non-rivality with JavaScript: the PyPI has currently 29444 vs 26256 for npm</font><br> <p> You are comparing a "batteries included" language with one that doesn't have a standard library.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545609/rss 2013-04-02T19:13:29+00:00 hummassa 1. std::uncaught_exception() allows for your commit/rollback scenario, but not your ignore_this_exception scenario. The latter does not seem a good idea to me, but...<br/> 2. the lock thing can be implicit... it's a matter of how you do it. Anyway, <pre> { some_lock_t lock(x); x.do_something(); } </pre>does not seem sooo wrong to me... although I usually put it on X and do<pre> x.do_something_locked&lt;some_lock_t&gt;(); </pre>only, or even<pre> some_locking_scaffold(x).do_something(); </pre>and this last one is really easy.<br/> 3. it's not! :-D PyCon: Evangelizing Python http://lwn.net/Articles/545593/rss 2013-04-02T17:23:38+00:00 intgr <div class="FormattedComment"> Similar, yes. Equivalent, no.<br> <p> 1. Python's "with" statement is more flexible, it has access to the exception when it occurs. A "with db_transaction():" block can automatically decide to commit or roll back, unlike C++/C#. You can also implement something like "with ignore_exception(OSError):"<br> <p> 2. Python doesn't require you to create a local variable to hold the state; this always annoys me when using the RAII pattern to hold locks in C++.<br> <p> 3. Prettier syntax ;)<br> <p> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545592/rss 2013-04-02T17:06:57+00:00 hummassa <div class="FormattedComment"> Every single C++ variable initialization is the equivalent to python's with and C#'s using...<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545584/rss 2013-04-02T16:15:10+00:00 lab <div class="FormattedComment"> <font class="QuotedText">&gt; Python is the only contemporary language I know that includes something like the with-statement, which does say something</font><br> <p> The C# 'using' statement?<br> <a href="http://msdn.microsoft.com/en-us/library/yh598w02">http://msdn.microsoft.com/en-us/library/yh598w02</a>(v=vs.110).aspx<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545500/rss 2013-04-01T22:57:54+00:00 nix <div class="FormattedComment"> Needless to say, nothing remotely as complicated as the protocols needed in Python to implement 'with' are needed in Lisp. The macro system and unwind-protect/dynamic-wind provides all you need, and implementing new with-*'s is a matter of a few lines of extremely not difficult code. (I emphasise this because macros can often be extremely arcane. Writing a with-blah isn't one of those: the most you have to worry about is a bit of variable capture.)<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545459/rss 2013-04-01T18:16:43+00:00 nybble41 <div class="FormattedComment"> In Common Lisp the form is known as "unwind-protect" [1], and in Scheme it's "dynamic-wind" [2]. The latter is more complicated because it attempts to handle the case where the inner code is re-entered through a continuation after the cleanup code has already been executed, but the idea is similar.<br> <p> Both expressions execute a block of code with a guarantee that some other code will be executed when control leaves the block, no matter how that happens (e.g. normal exit, exception, calling a continuation). Operations built on top of this mechanism often start with "with-" by convention, e.g. "with-open-file" (Common Lisp) and "call-with-input-file" (Scheme) both ensure that the file provided to the inner block is closed afterward.<br> <p> [1] <a href="http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node96.html">http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node96.html</a><br> [2] <a href="http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_idx_576">http://www.schemers.org/Documents/Standards/R5RS/HTML/r5r...</a><br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545436/rss 2013-04-01T16:16:17+00:00 kleptog <div class="FormattedComment"> Is it possible it's just because there are many people, like me, who don't know lisp and wouldn't know what a "with-statement in lisp" would look like if it stared them in the face. Certainly google isn't returning me any results, I guess they didn't call it the "with-statement" :). Perhaps someone who does know lisp should actually describe what it was the lisp did first.<br> <p> I hope people aren't just referring to lisp's ability to transform source code at compile time because that (IMO) trivialises what the with-statement adds to the language: the ability to factor out certain idioms that would otherwise require explicit handling of exceptions. There's a difference between "language X makes it possible to do idiom Y" and "language X includes explicit support for idiom X".<br> <p> While it may be that lisp did it first Python is the only contemporary language I know that includes something like the with-statement, which does say something.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545355/rss 2013-03-31T09:48:03+00:00 dark It's not really about trust. It's about embracing duck typing. <p>If you're parsing data from strings then by all means check that it's well-formed and that it's the kind of data you expect -- it's all under your control at that point. <p>If you're accepting a value from elsewhere, then it may make sense to do sanity checks on it, but those should be along the lines of "does it support the methods I expect to call on it", not "does it have the specific type I expect". The best example of this is file objects -- you really shouldn't enforce that it's a "file", you should let the caller pass in whatever file-like object is most convenient. <p>Most python code is simple enough that you can do those 'checks' just by calling the methods when you need them and getting an exception if they fail. But if you're about to insert such a received value into a complex system and you want to catch errors before they're deep in the stack then it may make sense to inspect the value a bit. Or just convert it -- calling int(value) or str(value) will throw exceptions right away, and the latter will let the value handle its own conversion. PyCon: Evangelizing Python http://lwn.net/Articles/545354/rss 2013-03-31T09:46:05+00:00 marcH <div class="FormattedComment"> <font class="QuotedText">&gt; Did he ever claim that these ideas were invented in Python? Did he say the word "innovative" even once in the talk?</font><br> <p> <font class="QuotedText">&gt; All he said is that these features set Python apart from other "scripting languages", wtih Perl and Ruby brought out as examples. </font><br> <p> In such a promotion speech context omitting references/credits creates a very fine line between the two. I can imagine the speaker saying the latter and the most of the audience misunderstanding the former (of course we'll never know).<br> <p> I don't think there should be things like "credits" in reference documents like PEPs (PEPs seem to have pointers to discussions which is more than enough).<br> <p> On the other hand I (finally) agree with jchrod: I expect a "Python's awesome" talk to give credit where it's due. Not just for honesty but also to help me develop my general software engineering culture and better understand *how* to create awesome things, i.e., by standing on the shoulder of giants, recombining existing ideas in new ways, and not patenting trivial prior art.<br> <p> <p> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545353/rss 2013-03-31T09:23:30+00:00 marcH <div class="FormattedComment"> <p> <font class="QuotedText">&gt; You shouldn't do type-checking of data passed in internal APIs; if your function accepts a string parameter, you don't check that it's string every time -- just assume that the caller got it right.</font><br> <p> "internal" can mean internal to either: your host, your process, your jar, your file, your company, your department, your team,... where does the trust stop? The answer probably depends on the task at hand. There is no simple answer.<br> <p> Searching for "Defensive Programming" should return a lot of simple - and extreme - answers. Make your own opinion somewhere in the middle...<br> <p> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545332/rss 2013-03-30T20:53:01+00:00 tnoo <div class="FormattedComment"> <font class="QuotedText">&gt; This hole is fixed in Python 3,</font><br> <p> Maybe I don't get it, but how should an undefined value d['age'] be compared to a number? The natural way is to compare int(d['age']) &lt; 18. which won't give random behaviour. and which would be done in any sane language. Nice that it raises Type error in Python3.<br> <p> <p> <p> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545328/rss 2013-03-30T20:18:52+00:00 serzan <div class="FormattedComment"> I did not say that it does.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545321/rss 2013-03-30T18:44:54+00:00 smurf Why should Python's indentation be a problem? <p> You use indentation in pretty much every other high-level programming language, otherwise you won't understand your code tomorrow.<br />The only difference is that Python uses the indents directly, while most other languages require redundant clutter like braces or BEGIN-END keywords to tell the compiler what to do. <p> Related to this, about everybody I know has written (or debugged) at least one piece of interesting C code like <p><pre> if (foo) if (bar) baz(); else quux(); </pre> You simply don't get to make these mistakes in Python. <p> Interestingly, the idea of indentation as primary syntax seems to spread to other contexts.<br /> Cf. CoffeeScript or HAML. PyCon: Evangelizing Python http://lwn.net/Articles/545319/rss 2013-03-30T18:02:12+00:00 jwakely <div class="FormattedComment"> How does C++ force any OO paradigm on you?<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545317/rss 2013-03-30T17:58:06+00:00 jwakely <div class="FormattedComment"> I have no problem at all with the indentation in a source file, but I wish the REPL was a bit smarter about handling the variations in whitespace that easily occur when selecting and pasting chunks of code.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545310/rss 2013-03-30T14:49:50+00:00 intgr <div class="FormattedComment"> <font class="QuotedText">&gt; Ah, the with statement. An innovative concept. Sigh. Those who don't know Lisp are condemned to reinvent it.</font><br> <p> <font class="QuotedText">&gt; Then evangelists (witness the talk from the article) come and present 30+ year old stuff as innovative concepts that's the best thing since sliced bread</font><br> <p> Did he ever claim that these ideas were invented in Python? Did he say the word "innovative" even once in the talk?<br> <p> All he said is that these features set Python apart from other "scripting languages", wtih Perl and Ruby brought out as examples. It's a true factual statement.<br> <p> Lisp isn't even on the radar for being a competitor to Python.<br> <p> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545308/rss 2013-03-30T14:26:18+00:00 intgr <blockquote>&gt; I needed to validate the types of data coming in from a json string and to do this I checked if the values I got back matched certain data types which apparently is a big no no in the world of python. Instead I'm supposed to use them as if they were those data types and wait for the world to explode when they aren't and pick up the pieces.</blockquote> <p>I believe there's a misunderstanding there. You shouldn't do type-checking of data passed in internal APIs; if your function accepts a string parameter, you don't check that it's string every time -- just assume that the caller got it right.</p> <p>However, if you're decoding JSON received from untrusted sources, then that kind of type checking makes sense and is often required to prevent some kinds of security bugs.</p> <p>Case in point with Python 2:</p> <pre> def check_age(data): d = json.loads(data) if d['age'] < 18: print "You must be 18 or older to continue." else: print "OK!" >>> check_age('{"age": 13}') You must be 18 or older to continue. >>> check_age('{"age": "13"}') OK! </pre> <p>This hole is fixed in Python 3, but in general there are still surprises you can run into if you allow arbitrary types from untrusted input.</p> PyCon: Evangelizing Python http://lwn.net/Articles/545301/rss 2013-03-30T12:25:52+00:00 thoeme <div class="FormattedComment"> Puh! And I thought *I* was only one being put off by python's use of identation... It always reminds of my miserable time in university using some retarded pascal interpreter on the school's VAX system. I tried to learn Python, but stopped imedeately when I found out that first example would not work due to 2 &lt;tab&gt;s in a block identation. Stupid design choice.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545276/rss 2013-03-30T03:57:24+00:00 nevets <div class="FormattedComment"> I totally agree with you. I had to work in that xen Python mess. It was horrible.<br> <p> Another problem I have with Python is that if I don't use it for a while, I have to always get my Python book out and relearn it. I'm a C programmer and Python is just so foreign to me. I rather program in Perl.<br> <p> Someone told me once that people who like to program in English prefer Python and those who prefer to program in math prefer Perl or C. I've also always had trouble reading pseudo code and preferred the actual code to look at.<br> </div> PyCon: Evangelizing Python http://lwn.net/Articles/545228/rss 2013-03-29T18:04:01+00:00 marcH <div class="FormattedComment"> <font class="QuotedText">&gt; Well, no (designers), partly (documentation and review) and yes (evangelists).</font><br> <p> Fair enough.<br> <p> <font class="QuotedText">&gt; you seem to take that much more as an attack as it's meant to.</font><br> <p> Well, it was an attack on "someone"... vague. Quite clearer now.<br> <p> </div>