{"id":150,"date":"2003-08-13T12:58:47","date_gmt":"2003-08-13T17:58:47","guid":{"rendered":"http:\/\/blogs.law.harvard.edu\/hoanga\/2003\/08\/13\/python-gotchas\/"},"modified":"2006-12-15T22:18:35","modified_gmt":"2006-12-16T03:18:35","slug":"python-gotchas","status":"publish","type":"post","link":"https:\/\/archive.blogs.harvard.edu\/hoanga\/2003\/08\/13\/python-gotchas\/","title":{"rendered":"Python gotchas"},"content":{"rendered":"<p><a name='a66'><\/a><\/p>\n<p>Got this link from <a href=\"http:\/\/www.sauria.com\/blog\/\">Ted Leung<\/a> on Python Programming pitfalls.   Looks like an interesting read and explains some of the more subtle behaviours of Python.<br \/>\nThe gotcha below I find really irksome:<\/p>\n<pre>\r\n&gt;&gt;&gt; t = ([],)\r\n&gt;&gt;&gt; t[0] += [2, 3]\r\nTraceback (most recent call last):\r\n  File \"\", line 1, in ?\r\nTypeError: object doesn't support item assignment\r\n&gt;&gt;&gt; t\r\n([2, 3],)\r\n<\/pre>\n<p>\nA tuple is an immutable (aka it shouldn&#8217;t be able to be changed) object in Python.  The += operator throws up a warning but goes ahead and changes it anyways.  Ummm&#8230; that&#8217;s dumb.   But all programming languages have their own sets of<br \/>\nannoyances.   My personal pet peeve with Python is that it&#8217;s really hard to integrate into the pipeline like Perl or Ruby.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Got this link from Ted Leung on Python Programming pitfalls. Looks like an interesting read and explains some of the more subtle behaviours of Python. The gotcha below I find really irksome: &gt;&gt;&gt; t = ([],) &gt;&gt;&gt; t[0] += [2, 3] Traceback (most recent call last): File &#8220;&#8221;, line 1, in ? TypeError: object doesn&#8217;t [&hellip;]<\/p>\n","protected":false},"author":703,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[972],"tags":[],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-programming"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/posts\/150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/users\/703"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":0,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"wp:attachment":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}