Re: Change one list item in place

2010-12-01 Thread Steven D'Aprano
On Wed, 01 Dec 2010 05:33:55 -0800, Gnarlodious wrote: > Thanks for all the ideas, I've resigned myself to unpacking a tuple and > reassembling it. You make it sound like that's an onerous task. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Change one list item in place

2010-12-01 Thread Jean-Michel Pichavant
Gnarlodious wrote: On Dec 1, 6:23 am, Jean-Michel Pichavant wrote: what about def query(): return ["Formating only {0} into a string".format(sendList()[0])] + sendList()[1:] However this solution calls sendList() twice, which is too processor intensive. You got to get rid of

Re: Change one list item in place

2010-12-01 Thread Gnarlodious
On Dec 1, 6:23 am, Jean-Michel Pichavant wrote: > what about > > def query(): >     return ["Formating only {0} into a string".format(sendList()[0])] + > sendList()[1:] However this solution calls sendList() twice, which is too processor intensive. Thanks for all the ideas, I've resigned myself

Re: Change one list item in place

2010-12-01 Thread Jean-Michel Pichavant
Gnarlodious wrote: This works for me: def sendList(): return ["item0", "item1"] def query(): l=sendList() return ["Formatting only {0} into a string".format(l[0]), l[1]] query() However, is there a way to bypass the l=sendList() and change one

Re: Change one list item in place

2010-12-01 Thread Steven D'Aprano
On Wed, 01 Dec 2010 08:54:49 +, Steven D'Aprano wrote: > An alternative would be: > Please ignore. That was an accidental Send mid-edit. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Change one list item in place

2010-12-01 Thread Steven D'Aprano
On Tue, 30 Nov 2010 17:08:57 -0800, Gnarlodious wrote: > This works for me: > > def sendList(): > return ["item0", "item1"] > > def query(): > l=sendList() > return ["Formatting only {0} into a string".format(l[0]), l[1]] For the record, you're not actually changing a list in place

Re: Change one list item in place

2010-11-30 Thread Steve Holden
g only {0} into a string".format(l[0]), l[1]] >> >> query() >> >> >> However, is there a way to bypass the >> >> l=sendList() >> >> and change one list item in-place? Possibly a list comprehension >> operating on a numbered item? >

Re: Change one list item in place

2010-11-30 Thread Gnarlodious
Thanks. Unless someone has a simpler solution, I'll stick with 2 lines. -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list

Re: Change one list item in place

2010-11-30 Thread MRAB
On 01/12/2010 01:08, Gnarlodious wrote: This works for me: def sendList(): return ["item0", "item1"] def query(): l=sendList() return ["Formatting only {0} into a string".format(l[0]), l[1]] query() However, is there a way to bypass the l=sendLi

Change one list item in place

2010-11-30 Thread Gnarlodious
This works for me: def sendList(): return ["item0", "item1"] def query(): l=sendList() return ["Formatting only {0} into a string".format(l[0]), l[1]] query() However, is there a way to bypass the l=sendList() and change one list item in-place?