{"id":303,"date":"2017-02-09T00:13:44","date_gmt":"2017-02-09T08:13:44","guid":{"rendered":"http:\/\/www.gregfina.com\/blog\/?p=303"},"modified":"2017-02-11T00:39:18","modified_gmt":"2017-02-11T08:39:18","slug":"python-tuples","status":"publish","type":"post","link":"https:\/\/www.gregfina.com\/blog\/2017\/02\/09\/python-tuples\/","title":{"rendered":"Python Tuples"},"content":{"rendered":"<p>No clue why Tuples in Python are immutable. \u00a0 It seems to me that this is a flaw in the language. \u00a0 I&#8217;m no expert on underlying programming language architecture. \u00a0 \u00a0But it seems to me that if I want a<\/p>\n<p><pre><code>\nmyTuple = {(&#039;NAMED1&#039;:variable1,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;NAMED2&#039;:variable2,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;NAMED3&#039;:variable3)}\n<\/code><\/pre><br \/>\nWhere there is some interrelation between variable1, variable2 and variable3. If I subsequently what to set NAMED3 to new variable4.   There is no way to do this.  <\/p>\n<p>Wouldn&#8217;t it be nice if one could do?<br \/>\n<pre><code>&nbsp;&nbsp;\nmyTuple[&#039;NAMED3&#039;] = variable4 \n<\/code><\/pre><\/p>\n<p>So now I&#8217;d have:<br \/>\n<pre><code>\nmyTuple = {(&#039;NAMED1&#039;:variable1,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;NAMED2&#039;:variable2,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;NAMED3&#039;:variable4)}\n<\/code><\/pre><\/p>\n<p>This fails because of Tuples immutability. <\/p>\n<p>One way to overcome this is create a new Tuple and then delete the existing Tuple. \u00a0 \u00a0This becomes very interesting when I have \u00a0list of Tuples were you make a new tuple add it to the list and delete the existing Tuple.<\/p>\n<p>Seems like a lot of hassle for a language which is suppose to be very programmer friendly.   <\/p>\n","protected":false},"excerpt":{"rendered":"<p>No clue why Tuples in Python are immutable. \u00a0 It seems to me that this is a flaw in the language. \u00a0 I&#8217;m no expert on underlying programming language architecture. \u00a0 \u00a0But it seems to me that if I want a myTuple = {(&#039;NAMED1&#039;:variable1, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;NAMED2&#039;:variable2, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;NAMED3&#039;:variable3)} Where there is some interrelation between variable1, variable2 and &hellip; <a href=\"https:\/\/www.gregfina.com\/blog\/2017\/02\/09\/python-tuples\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Python Tuples&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[14],"tags":[],"class_list":["post-303","post","type-post","status-publish","format-standard","hentry","category-tech"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p46b0T-4T","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/posts\/303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/comments?post=303"}],"version-history":[{"count":13,"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/posts\/303\/revisions"}],"predecessor-version":[{"id":316,"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/posts\/303\/revisions\/316"}],"wp:attachment":[{"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/media?parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/categories?post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gregfina.com\/blog\/wp-json\/wp\/v2\/tags?post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}