Converting to lists into one dictionary

Greg Ewing greg.ewing at compaq.com
Tue Oct 5 06:53:03 EDT 1999


Brian E Gallew wrote:
> 
> Because there is no obviously correct behaviour for such a function.
> Two obvious cases:
> a) dict(list1, list2) # What should it do if the lists aren't the same
> size?
> b) dict(list1) # Is list1 keys, values, or both?

There should be 2 ways of calling it:

   dict(keys = [...], values = [...]) 
	# exception raised if lists not the same length

   dict(items = [(k, v),...])

and the keywords should be compulsory, so that it's always
clear what is being done.

Greg




More information about the Python-list mailing list