{"id":516,"date":"2008-08-05T12:12:49","date_gmt":"2008-08-05T16:12:49","guid":{"rendered":"http:\/\/www.dr-chuck.com\/wordpress\/?p=516"},"modified":"2011-12-17T12:27:08","modified_gmt":"2011-12-17T16:27:08","slug":"today-my-favourite-feature-of-python-at-least-for-today","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2008\/08\/today-my-favourite-feature-of-python-at-least-for-today\/","title":{"rendered":"Today: My Favourite Feature of Python (at least for today)"},"content":{"rendered":"<p>I have been doing object oriented stuff before the word was coined.  I have tried all the languages (except LISP) and each has bits to like.  But the feature where I can manufacture a return object on the fly is simply too awsome for words!<\/p>\n<p>\nIt completes Object orientation &#8211; and yes I know &#8211; it was stolen from \/ homage to LISP.  OK &#8211; I admit is LISP was right on 5% of its language.<\/p>\n<p>\nHere is my snippet &#8211; a silly bit of code.<\/p>\n<pre>\ndef addandsub(a,b) :\nreturn (a + b, a - b)\nprint \"Hello\"\n(x,y)  = addsub(10, 4)\nprint x,y\n<\/pre>\n<p>\nI returned a tuple with two integers &#8211; it solves the sucky single primitive return value of Java and C++ which both inherited from C.<\/p>\n<p>\nPerhaps this is the strength of Python &#8211; it inherits from C, PERL, and LISP and mixes them nicely to make a new life form with superior hybrid genetics.  HURRAY!<\/p>\n<p>\n<b>Update:<\/b> Thanks to Stuart Feeeman from Georgia Tech, the right way to make an empty block is to use the &#8220;pass&#8221; statement.<\/p>\n<p>\nOk &#8211; while I am gushing &#8211; I should explain what bothers me the most is the fact I cannot make an empty bracket like this<\/p>\n<pre>\nif x < y :\n# Do nothing here\nelse:\nprint \"Hello\"\n<\/pre>\n<p>\nI want to have the first part of the brace to be empty - but nooooo - I can't do that.   I have to do this:<\/p>\n<pre>\nif x &lt; y :\npass # I love an explicit no-op in a language\nelse:\nprint \"Hello\"\n<\/pre>\n<p>\nThanks Stuart!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been doing object oriented stuff before the word was coined. I have tried all the languages (except LISP) and each has bits to like. But the feature where I can manufacture a return object on the fly is simply too awsome for words! It completes Object orientation &#8211; and yes I know &#8211; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-516","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=516"}],"version-history":[{"count":1,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/516\/revisions"}],"predecessor-version":[{"id":2617,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/516\/revisions\/2617"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}