Re: Building a dictionary from a tuple of variable length

2007-03-05 Thread Pierre Quentel
Hi, > Therefore, how do I build the tuple of Falses to reflect the length of my t > tuple? Yet another solution : d = dict(zip(t,[False]*len(t))) Pierre -- http://mail.python.org/mailman/listinfo/python-list

Re: Building a dictionary from a tuple of variable length

2007-03-05 Thread Jussi Salmela
[EMAIL PROTECTED] kirjoitti: > Hi, > > I have the following tuple - > > t = ("one","two") > > And I can build a dictionary from it as follows - > > d = dict(zip(t,(False,False))) > > But what if my tuple was - > > t = ("one","two","three") > > then I'd have to use - > > d = dict(zip(t,(Fals

Re: Building a dictionary from a tuple of variable length

2007-03-05 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I have the following tuple - > > t = ("one","two") > > And I can build a dictionary from it as follows - > > d = dict(zip(t,(False,False))) > > But what if my tuple was - > > t = ("one","two","three") > > then I'd have to use - > > d = dict(zip(t,(False,False,Fals

Re: Building a dictionary from a tuple of variable length

2007-03-05 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, bg_ie wrote: > Therefore, how do I build the tuple of Falses to reflect the length of > my t tuple? In [1]: dict.fromkeys(('one', 'two', 'three'), False) Out[1]: {'three': False, 'two': False, 'one': False} Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org

Building a dictionary from a tuple of variable length

2007-03-05 Thread bg_ie
Hi, I have the following tuple - t = ("one","two") And I can build a dictionary from it as follows - d = dict(zip(t,(False,False))) But what if my tuple was - t = ("one","two","three") then I'd have to use - d = dict(zip(t,(False,False,False))) Therefore, how do I build the tuple of Falses