On Jun 8, 7:27 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
> "Karlo Lozovina" <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
> | I figured that out few minutes ago, such a newbie mistake :). The fix I
> | came up with is:
> |
> |  result = ['something'] + [someMethod(i) for i in some_list]
> |
> | Are there any other alternatives to this approach?
>
> result = [something]
> result.extend(someMethod(i) for i in some_list)
>
> avoids creating and deleting an intermediate list

or:
result = ['something'].extend(someMethod(i) for i in some_list)

it also avoids intermediate list and is one line.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to