On Thu, May 27, 2010 at 5:47 PM, Tim Chase <python.l...@tim.thechases.com>wrote:
> On 05/27/2010 03:32 PM, Victor Subervi wrote: > > On Thu, May 27, 2010 at 1:15 PM, Tim Chase wrote: >> >>> That should be: >>>> >>>> ', '.join(['%s'] * len(values))) >>>> >>> >>> Or as I've done in the past: >>> >>> ', '.join('%s' for _ in values) >>> >> >> Huh? Can you describe that underscore to me? Fascinating! >> > > The underscore is a valid variable-name, idiomatically used for "I don't > care about this", often seen in places like tuple assignment: > > a,_,_,d = some_4_element_tuple > > So in my above case, it could also have been written as > > ', '.join('%s' for value in values) > ', '.join('%s' for dont_care_about_the_value in values) > > but the "_" idiom means "I'm iterating over 'values' but I'm not actually > using the values I get from it" > I should have known. Thanks! beno
-- http://mail.python.org/mailman/listinfo/python-list