Python - Pass a variable to lambda if it exists
<p>I'm curious about how to make code more efficient in Python, I've got to execute an action, which may or may not have a payload attached depending on the length of a list.</p>

<p>Right now, I'm using an if statement to determine if there is a payload. Is there a better or cleaner way to find this?</p>

<pre><code>                    #If payload, execute action with it
                    if(len(data) &gt; 1):
                        action= mec.action(data[1])
                    #If no payload, then just execute action
                    else:
                        action= mec.action()
                    return action
</code></pre>