One line to check if string or list, then convert to list in Python : <p>Suppose I have an object <code>a</code> that can either be a string (like <code>'hello'</code> or <code>'hello there'</code>) or a list (like <code>['hello', 'goodbye']</code>). I need to check if <code>a</code> is a string or list. If it's a string, then I want to convert it to a one element list (so convert <code>'hello there'</code> to <code>['hello there']</code>). If it's a list, then I want to leave it alone as a list.</p>

<p>Is there a Pythonic one-line piece of code to do this? I know I can do:</p>

<pre><code>if isinstance(a, str):
    a = [a]
</code></pre>

<p>But I'm wondering if there's a more direct, more Pythonic one-liner to do this.</p>
