title: Function Argument Packing And Unpacking Python
body: <p>Currently, I have a function like so:</p>
  
  <pre><code>def my_func(*args):
      #prints amount of arguments
      print(len(args))
      #prints each argument
      for arg in args:
          print(arg)
  </code></pre>
  
  <p>I want to put multiple arguments through to this function, but the following doesn't work for me. It gives out a syntax error on the asterisk * after the else.</p>
  
  <pre><code>my_func(
      *(1, 2, 3, 4)
      if someBool is True
      else *(1, 2)
  )
  </code></pre>
  
  <p>The workaround I found puts 1 and 2 in first and then puts 3 and 4 while checking for someBool.</p>
  
  <pre><code>my_func(
      1, 2,
      3 if someBool is True else None,
      4 if someBool is True else None
  )
  </code></pre>
  
  <p>I am fine with the above as my function checks for None but if there is an alternative I would gladly thank them.</p>