Can list comprehension have a prefix, suffix?
<p>I need to create a list comprehension and add one extra item at the start and end. Is there a better way than just using a helper function to do it?</p>

<pre><code># convert tuple from permutation into a list with predecessor and successor
def perm_to_list(predecessor, perm, successor):
    result = [predecessor]
    result.extend(list(perm))
    result.append(successor)
    return result

candidates = [perm_to_list(prefix, x, suffix) 
              for x in permutations(something)] 
</code></pre>

<p>There is a new <a href="https://www.python.org/dev/peps/pep-0448/" rel="nofollow">feature</a> available only in Python 3.5:</p>

<p>Unpacking of iterables anywhere in a list:</p>

<pre><code>[prefix, *iterable, suffix]
</code></pre>

<p>(I wish they added it sooner)</p>

python list-comprehension