title: Any way to put an if statement in the function call argument?
body: <p>I found out that we can use the ternary op inside the function call argument:</p>
  
  <pre class="lang-py prettyprint-override"><code>def foo(n):
      print(n)
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code>a, b = 1, 2
  foo(a if a&gt;b else b)
  # prints 2
  </code></pre>
  
  <p>I wonder is there a way to use if without the else in the function call argument? so something like if it's true, pass a to it, if not, don't pass anything.</p>
  
  <p>I've tried</p>
  
  <pre class="lang-py prettyprint-override"><code>foo(a if a&gt;b else pass)
  foo(a if a&gt;b)
  foo(if a&gt;b: a)
  foo(a&gt;b and a)
  </code></pre>
  
  <p>None of the above works.</p>
  
  <p>Thanks for your help.</p>
  
  <p>Edit-----</p>
  
  <p>Sorry, let me rephrase my question.</p>
  
  <p>What I'm asking for is a way to determine whether I should pass the argument based on a condition.</p>
  
  <p>So basically I have to call a big function that takes a lot of kwargs, say:</p>
  
  <pre class="lang-py prettyprint-override"><code># function call
  thefunc(
      a=1,
      b=2,
      c=3,
      d=4,
      e=5
      #...
  )
  </code></pre>
  
  <p>And all of the args are options which its up to me, or in some cases, a condition.</p>
  
  <p>Since the argument list is so big that writing function calls inside the if statement is not preferred, so I need to know is there a way to, say:</p>
  
  <pre class="lang-py prettyprint-override"><code>thefunc(
      a=1,
      #if condition: b=2,
      c=3,
      ....
  )
  </code></pre>
  
  <p>So to determine whether to give the kwarg or not. Its okay if there isn't, just need to know, thanks.</p>