c = {x: '' for x in a}
Steve Holden
sholden at holdenweb.com
Fri Mar 7 08:57:19 EST 2003
"Aurelio Martin Massoni" <amartin at traza-si.com> ...
>
> "Hilbert" <hilbert at microsoft.com> escribió en el mensaje
> news:v6gp1841qlpr51 at corp.supernews.com...
> > Ok.
> > This works:
> >
> > a = [1,2,3]
> > b = [x for x in a]
> >
> > What's wrong with this one though? It would totally make sense to
> me...
> >
> > a = [1,2,3]
> > c = {x: '' for x in a}
>
> Try this one :
>
> c = dict( [ ( x, '' ) for x in a ] )
>
and, in Python 2.3
c = sets.Set([1,2,3])
depending-of-course-on-your-requirements-ly y'rs - steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
Register for PyCon now! http://www.python.org/pycon/reg.html
More information about the Python-list
mailing list