Yet Another MySQL Problem

Victor Subervi victorsubervi at gmail.com
Fri May 28 08:06:10 EDT 2010


On Thu, May 27, 2010 at 5:47 PM, Tim Chase <python.list at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100528/0d00251b/attachment-0001.html>


More information about the Python-list mailing list