Re: Process tuple contents on the fly

2013-04-15 Thread Gnarlodious
On Monday, April 15, 2013 2:35:10 PM UTC-6, Tobiah wrote: > > tup = *func() > What is the asterisk for? I assume it's a python 3 Not Python 3, pseudocode. I should have said as such, sorry. Supposed to indicate an expanded tuple. -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-li

Re: Process tuple contents on the fly

2013-04-15 Thread Michael Torrie
On 04/15/2013 02:35 PM, Tobiah wrote: > On 04/15/2013 11:25 AM, Gnarlodious wrote: >> Say I have a tuple I want to expand assigning to variables: >> >> tup = *func() > > What is the asterisk for? I assume it's a python 3 > thing, because I get a syntax error, but I'm having > trouble Googling it.

Re: Process tuple contents on the fly

2013-04-15 Thread Tobiah
On 04/15/2013 11:25 AM, Gnarlodious wrote: Say I have a tuple I want to expand assigning to variables: tup = *func() What is the asterisk for? I assume it's a python 3 thing, because I get a syntax error, but I'm having trouble Googling it. Thanks, Tobiah -- http://mail.python.org/mailman/

Re: Process tuple contents on the fly

2013-04-15 Thread MRAB
On 15/04/2013 20:05, Barrett Lewis wrote: d = {} for key, d[key] in (("this",18), ("that",17), ("other",38)): print key do_something(d) Why not use a dict comprehension? d = {k:v for k,v in (("this",18), ("that",17), ("other",38))} I feel this is more straig

Re: Process tuple contents on the fly

2013-04-15 Thread Barrett Lewis
> In the particular case I did it in, I needed the incremental results > passed to a function, not just the final result. I don't think this > made it into the final code, rather it was expanded to be more > readable. But the discovery made me feel a disturbance in the > Pythonic force of the uni

Re: Process tuple contents on the fly

2013-04-15 Thread Tim Chase
On 2013-04-15 12:05, Barrett Lewis wrote: > > d = {} > > for key, d[key] in (("this",18), ("that",17), ("other",38)): > > print key > > do_something(d) > > Why not use a dict comprehension? > d = {k:v for k,v in (("this",18), ("that",17), ("other",38))} > > I feel this is more straig

Re: Process tuple contents on the fly

2013-04-15 Thread Peter Otten
Tim Chase wrote: > 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

Re: Process tuple contents on the fly

2013-04-15 Thread Barrett Lewis
> d = {} > for key, d[key] in (("this",18), ("that",17), ("other",38)): > print key > do_something(d) > Why not use a dict comprehension? d = {k:v for k,v in (("this",18), ("that",17), ("other",38))} I feel this is more straightforward and easier to read. the results are the same how

Re: Process tuple contents on the fly

2013-04-15 Thread Tim Chase
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 > possib