{"id":5031,"date":"2014-03-30T18:08:00","date_gmt":"2014-03-30T18:08:00","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/passing-method-result-as-argument-to-other-method-collection-of-common-programming-errors\/"},"modified":"2014-03-30T18:08:00","modified_gmt":"2014-03-30T18:08:00","slug":"passing-method-result-as-argument-to-other-method-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/passing-method-result-as-argument-to-other-method-collection-of-common-programming-errors\/","title":{"rendered":"Passing method result as argument to other method-Collection of common programming errors"},"content":{"rendered":"<p>You are trying to supply a value where Python expects a simple name; that name will be assigned a value at runtime.<\/p>\n<p>Since <code>self<\/code> is already an argument, you can probably just call <code>self.method1()<\/code> when <code>method2<\/code> is run:<\/p>\n<pre><code>def method2(self)\n    x = self.method1()\n<\/code><\/pre>\n<p>If you want the default value for a parameter to be set by <code>method1<\/code>, use <code>None<\/code> as a default value.<\/p>\n<pre><code>def method2(self, var=None):\n    if var is None:\n        var = self.method1()\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You are trying to supply a value where Python expects a simple name; that name will be assigned a value at runtime. Since self is already an argument, you can probably just call self.method1() when method2 is run: def method2(self) x = self.method1() If you want the default value for a parameter to be set [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5031","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5031"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5031\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}