Python return value
<p>I have a global variable <code>global_a</code> and the function to determine the value</p>

<pre><code># long Syntax
def assignement_a():
  global_a = len(xyz)
  return global_a
</code></pre>

<p>The point is to return the value to caller and simultaneously assign the value to the global to saved for further use, so I need something like this</p>

<pre><code># shorter syntax
def assignement_a():
  return global_a = len(xyz)
</code></pre>

<p>Is there a short syntax solution in python?</p>

<p>Just for the record, the correct version of "long syntax" is:</p>

<pre><code>def assignement_a():
  global global_a
  global_a = len(xyz)
  return global_a
</code></pre>

<p>As for the "short syntax" I don't see why it would be necessary here. Maybe it can be made shorter using a lambda, but that might just obscure the purpose of this function. Further using globals is not really a best practice anyway and is why Python requires you to be explicit about it (that and the way Python handles variable scope)</p>

python function return-value