Creating A Tuple From A List, Adding To Tuple As You Do

Paul McGuire ptmcg at austin.rr.com
Thu Jun 5 14:50:45 CEST 2008


On Jun 5, 7:41 am, Jeff Nyman <jeffny... at gmail.com> wrote:
> DC_List = ['Baltimore', 'Birmingham', 'Cincinnati', 'Cleveland',
> LosAngeles']
>
> (Each element in the DC_List is actually a full directory path, but I
> shortened that in the interest of clarity.)
>
> The problem is that I need to pass this list to a list control in a
> wxWidgets application. In order to do that, I need to pass in a list
> like this:
>
> [ ('Baltimore', ''), ('Birmingham', ''), ('Cincinnati', ''),
> ('Cleveland', ''), ('LosAngeles', '') ]
>

tupleized_city_list = [ (city,'') for city in DC_list ]

-- Paul





More information about the Python-list mailing list