On 2013-04-15 11:25, Gnarlodious wrote:
> Say I have a tuple I want to expand assigning to variables:
>
> tup = *func()
> var = tup[0]
> lst.append(tup[1])
>
> Or could I do it in one line?
>
> var, lst.append() = *func()
>
> So I want to append one variable to a list on the fly, is it
> possible?
I stumbled across this atrocity[*], which if you chose to use it,
you'd deserve a kick in the pants:
lst.append("Value I don't care about and will overwrite")
var, lst[-1] = *func()
It's not quite one step, but at least the *assignment* is one step :-)
-tkc
[*] my original discovery was
d = {}
for key, d[key] in (("this",18), ("that",17), ("other",38)):
print key
do_something(d)
but the same applies to a plain ol' assignment statement as to an
assignment in a "for" loop.
--
http://mail.python.org/mailman/listinfo/python-list